Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.