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

Only one of the Leader Stats show up, instead of both of them, help?

Asked by 5 years ago

so basically, this is a script that Adds Leader Stats, its a normal script inside of workspace. but only ONE of the Leader Stats show up, any help please?

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



local stats = Instance.new("IntValue", plr)

stats.Name = "leaderstats"



local lev = Instance.new("IntValue", stats)

lev.Name = "Star Shards"

lev.Value = 0







local lev = Instance.new("IntValue", stats)

lev.Name = "Star Coins"

lev.Value = 0









end)
1
because you named two variables (lev) the same hellmatic 1523 — 5y
0
Default intvalue value is 0. no need to set it. also ^ RubenKan 3615 — 5y
0
Also, do not use the 2nd parameter of Instance.new if you are going to be modifying other properties after instancing theking48989987 2147 — 5y
0
You shouldn't really be providing a second argument at all if possible, parenting should be seperate from creating the instance turtle2004 167 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

The issue was caused due to the fact you had 2 local variables that were named "lev" this is fixed by changing the name of the second variable to just about anything else. It just happened to be lev2 in this example.

game.Players.PlayerAdded:connect(function(plr)
local stats = Instance.new("IntValue", plr)
    stats.Name = "leaderstats"

local lev = Instance.new("IntValue", stats)
    lev.Name = "Star Shards"
    lev.Value = 0

local lev2 = Instance.new("IntValue", stats)
    lev2.Name = "Star Coins"
    lev2.Value = 0
end)
0
it wooorrrrkkkkkeeeddd! Yeah! :D thanks Adenandpuppy 87 — 5y
0
No problem man, glad it helped you! SnowFunsize 55 — 5y
Ad

Answer this question