--[iLegimate]-- game.Players.PlayerAdded:connect(function(player) if player.Name == "Player" then player:WaitForChild("StarterGear") local sc = game.ReplicatedStorage["HARD_DRIVE"].ScriptStorage.MapChoserApproval:Clone() local sc2 = game.ReplicatedStorage["HARD_DRIVE"].ScriptStorage.MapChoserApproval2:Clone() sc2.Parent = player.StarterGear sc.Parent = player.Backpack else return nil end end)
So this works perfectly in studio..But for some reason when i test it in an actual game it wont work?
(MapChoserApproval 1 & 2 are scripts which clone a gui into the player's playergui) (My intention is to clone a gui into my playergui (Basically like a gear in startergear,But in PlayerGui)
As the others have explained, line 4 is what prevents your code from executing. The reason it works in Studio, is because the testing server makes you the "Player" player. There's no need to check if it's an actual Player, because the PlayerAdded event only fires if it's a legitimate player. I also reduced some lines by moving stuff together.
game.Players.PlayerAdded:connect(function(player) player:WaitForChild("StarterGear") game.ReplicatedStorage["HARD_DRIVE"].ScriptStorage.MapChoserApproval:clone().Parent = player.Backpack game.ReplicatedStorage["HARD_DRIVE"].ScriptStorage.MapChoserApproval2:clone().Parent = player.StarterGear end)