When a player joins a Gui, script and Sound is supposed to be put in their PlayerGui and Backpack. However Backpack is not a valid member of Player? Help?
local function onPlayerEntered(newPlayer) local a = script.Gui:Clone() a.Parent = newPlayer.PlayerGui local b = script.CamFix:Clone() b.Parent = newPlayer.Backpack newPlayer.Backpack.CamFix.Disabled = false local c = Instance.new("Sound") c.Parent = newPlayer.PlayerGui c.SoundId = "http://www.roblox.com/asset/?id=142725769" c.Volume = 1 newPlayer.PlayerGui.Sound:Play() print(newPlayer.Name) end game.Players.PlayerAdded:connect(onPlayerEntered) for i,v in pairs (game.Players:getChildren()) do onPlayerEntered(v) end
Try waiting for the Backpack and PlayerGui to be added to the Player object before you attempt to use them using the WaitForChild
function.
newPlayer:WaitForChild("Backpack") newPlayer:WaitForChild("PlayerGui")
This is what I always do at the top since WaitForChild sometimes waits for infinity:
newPlayer.CharacterAdded:wait() wait(1)