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

Why isnt My script working when i start a local server?

Asked by 7 years ago

I have made an instance of a Melee level like this:

-Localscript game.Players.PlayerAdded:connect(function(plr)

_G.leader = Instance.new("IntValue", plr) _G.leader.Name = "leaderstats"

_G.Melee = Instance.new("IntValue", leader) _G.Melee.Name = "Melee" _G.Melee.Value = 0

end)

Textlabel that displays Melee Value:

game.Players.LocalPlayer.leaderstats:WaitForChild("Melee")

While true do script.Parent.Text = _G.Melee.Value

wait(3) end

The result of testning in studio would be 0 but when i start a local server IT shows nothing. The output is also nothing.

1 answer

Log in to vote
0
Answered by 7 years ago

Your issue is that PlayerAdded won't really fire on LocalScripts like that. Instead, try something like this.

plr = game.Players.LocalPlayer

_G.leader = Instance.new("IntValue", plr) _G.leader.Name = "leaderstats"

_G.Melee = Instance.new("IntValue", leader) _G.Melee.Name = "Melee" _G.Melee.Value = 0

Ad

Answer this question