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

Why don't this simple leader-board script work in a client server?

Asked by 9 years ago
01game.Players.PlayerAdded:connect(function(plr)
02    local stats = Instance.new("IntValue", plr)
03    stats.Name = "leaderstats"
04    local Cash = Instance.new("IntValue", stats)
05    Cash.Value = 0
06    Cash.Name = "Cash"
07 
08 
09 
10end)
11 
12 
13while true do
14    wait(1.5)
15        game.Players.LocalPlayer.leaderstats.Cash.Value = game.Players.LocalPlayer.leaderstats.Cash.Value + 100
16        print("Given You 100$")
17 
18 
19end

I tried with a localscript/script

and dont work

(Tycoon game)

If you still don't understand im talking about it works in roblox studio but when join as a player not studio mode the leader-board don't show up

1 answer

Log in to vote
0
Answered by 9 years ago

You should just give values for the player. dont do it for every player if your going to use a LocalPlayer. because each localscript that goes into specific services is cloned into each player

01    local plr =   game.Players.LocalPlayer 
02 
03    local stats = Instance.new("IntValue", plr)
04    stats.Name = "leaderstats"
05 
06    local Cash = Instance.new("IntValue", stats)
07    Cash.Value = 0
08    Cash.Name = "Cash"
09 
10while true do
11    wait(1.5)
12        plr.leaderstats.Cash.Value = game.Players.LocalPlayer.leaderstats.Cash.Value + 100
13        print("Given You 100$")
14 
15 
16end
Ad

Answer this question