Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Working in Roblox studio but not in Game?

Asked by
RoyMer 301 Moderation Voter
9 years ago

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.

01function onPlayerEntered(newPlayer)
02    wait(.1)
03    local stats = Instance.new("IntValue")
04    stats.Name = "leaderstats"
05    local stats2 = Instance.new("IntValue")
06    stats2.Name = "Tycoon"
07 
08    stats2.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 
16end
17 
18game.Players.ChildAdded:connect(onPlayerEntered)
0
Is this a Script or a LocalScript? BlueTaslem 18071 — 9y
0
if it works in studio im guessing it's not a script.. HungryJaffer 1246 — 9y
0
>game.Players.LocalPlayer, can only be used in a LocalScript xolbStudios 127 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago
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.
03function onPlayerEntered(newPlayer)
04    wait(.1)
05    local stats = Instance.new("IntValue")
06    stats.Name = "leaderstats"
07    local stats2 = Instance.new("IntValue")
08    stats2.Name = "Tycoon"
09 
10    stats2.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.
View all 21 lines...
0
Thanks alot! RoyMer 301 — 9y
0
Np legomaster38 39 — 9y
Ad

Answer this question