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
8 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.

function onPlayerEntered(newPlayer) 
    wait(.1) 
    local stats = Instance.new("IntValue") 
    stats.Name = "leaderstats"
    local stats2 = Instance.new("IntValue") 
    stats2.Name = "Tycoon" 

    stats2.Parent = newPlayer 
    stats.Parent = newPlayer        

    wait(.1)
    local clone=game.ReplicatedStorage:FindFirstChild("GUIs"):FindFirstChild("JoinGui")
    local player = game.Players.LocalPlayer 
    clone.Parent = player.PlayerGui

end

game.Players.ChildAdded:connect(onPlayerEntered) 
0
Is this a Script or a LocalScript? BlueTaslem 18071 — 8y
0
if it works in studio im guessing it's not a script.. HungryJaffer 1246 — 8y
0
>game.Players.LocalPlayer, can only be used in a LocalScript xolbStudios 127 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago
--If your planing to use the onPlayerEntered event then you might as well stick to Script aka Server Sided scripting.
--Do not just randomly add **LocalPlayer** and mix it up with server side and client side.
function onPlayerEntered(newPlayer) 
    wait(.1) 
    local stats = Instance.new("IntValue") 
    stats.Name = "leaderstats"
    local stats2 = Instance.new("IntValue") 
    stats2.Name = "Tycoon" 

    stats2.Parent = newPlayer 
    stats.Parent = newPlayer        

    wait(.1)
    local clone=game.ReplicatedStorage:FindFirstChild("GUIs"):FindFirstChild("JoinGui")
    local player = newPlayer -- I have changed it to newPlayer since you had the argument setup since before. 
    clone.Parent = player.PlayerGui

end

game.Players.PlayerAdded:connect(onPlayerEntered) --Also I am changing it to PlayerAdded
--if this helped leave a upvote thanks.
0
Thanks alot! RoyMer 301 — 8y
0
Np legomaster38 39 — 8y
Ad

Answer this question