So I'm trying to save a variable from my datastore into my playergui... it seems that "Settings" isn't replicating into PlayerGui tho (despite being in StarterGui) and this is gamebreaking. This doesn't happen in studio (although I haven't got API enabled in studio, so that might do it).
Script that seems to be causing problems:
local function setupPlayerData(player)
local data = playerData:GetAsync(player.UserId)
if not data then
print("Data not found for " + player)
data = {["Monster"] = "Ghost"}
playerData:SetAsync(player.UserId, data)
end
sessionData[player] = data
player.PlayerGui:WaitForChild("Settings")
player.PlayerGui.Settings.PlayerMonster.Value = sessionData[player]["Monster"]
end
And where it is called in the code (from beginning):
game.Players.PlayerAdded:connect(function(player) --Sets up new players
player.CharacterAdded:connect(function(character)
character.Humanoid.JumpPower = 0
character.Humanoid.Died:connect(function(humanoid)
character:FindFirstChild('Humanoid'):UnequipTools()
player.Backpack:ClearAllChildren()
if player.TeamColor ~= BrickColor.new("Really red") and game.Workspace.Round.Value == true then
player.TeamColor = BrickColor.new("Bright red")
player.CharacterAdded:wait()
waitForCharacter(player)
morph(player, monsterType)
end
end)
end)
setupPlayerData(player)
end)
All help appreciated! Thanks,
-Snaptor |