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

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

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)

4 comments

1

because you named two variables (lev) the same

0

Default intvalue value is 0. no need to set it. also ^

0

Also, do not use the 2nd parameter of Instance.new if you are going to be modifying other properties after instancing

0

You shouldn't really be providing a second argument at all if possible, parenting should be seperate from creating the instance

1 answer

✓ Accepted answer

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)

2 comments

0

it wooorrrrkkkkkeeeddd! Yeah! :D thanks

0

No problem man, glad it helped you!

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