This is the full script, what I'm trying to do is to make the GUI only appear only once which is when the player joins the game, it is working in Roblox Studio but not in actual Roblox Game.
01 | function onPlayerEntered(newPlayer) |
02 | wait(. 1 ) |
03 | local stats = Instance.new( "IntValue" ) |
04 | stats.Name = "leaderstats" |
05 | local stats 2 = Instance.new( "IntValue" ) |
06 | stats 2. Name = "Tycoon" |
07 |
08 | stats 2. Parent = newPlayer |
09 | stats.Parent = newPlayer |
10 |
11 | wait(. 1 ) |
12 | local clone = game.ReplicatedStorage:FindFirstChild( "GUIs" ):FindFirstChild( "JoinGui" ) |
13 | local player = game.Players.LocalPlayer |
14 | clone.Parent = player.PlayerGui |
15 |
16 | end |
17 |
18 | game.Players.ChildAdded:connect(onPlayerEntered) |
01 | --If your planing to use the onPlayerEntered event then you might as well stick to Script aka Server Sided scripting. |
02 | --Do not just randomly add **LocalPlayer** and mix it up with server side and client side. |
03 | function onPlayerEntered(newPlayer) |
04 | wait(. 1 ) |
05 | local stats = Instance.new( "IntValue" ) |
06 | stats.Name = "leaderstats" |
07 | local stats 2 = Instance.new( "IntValue" ) |
08 | stats 2. Name = "Tycoon" |
09 |
10 | stats 2. Parent = newPlayer |
11 | stats.Parent = newPlayer |
12 |
13 | wait(. 1 ) |
14 | local clone = game.ReplicatedStorage:FindFirstChild( "GUIs" ):FindFirstChild( "JoinGui" ) |
15 | local player = newPlayer -- I have changed it to newPlayer since you had the argument setup since before. |