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

pls help me create my leaderstats?

when i run this it adds coin and rebirgth to me in addition to my cash and energy but in my script i asked for cash and energy can you help me create my leaderstats!

my code :

function onPlayerEntered(newPlayer) wait(.5) local stats = Instance.new("IntValue") stats.Name = "leaderstats"

local score = Instance.new("IntValue")

score.Name = "Cash" -- Change "Cash" with Your Leaderstats Name
score.Value = 0

score.Parent = stats
stats.Parent = newPlayer

local score = Instance.new("IntValue")

score.Name = "Energy" -- Change "Energy" with Your Leaderstats Name
score.Value = 0

score.Parent = stats
stats.Parent = newPlayer

end

2 comments

0

stats is a "Folder" not an "IntValue".

0

S'il vous plaît, pouvez-vous m'écrire mon script

1 answer

What your problem is, is that you made stats an intvalue, not a folder and for leaderstats you would need to use a folder. Here is what you could do:

function onPlayerEntered(newPlayer) wait(.5)
local stats = Instance.new("Folder")
stats.Name = "leaderstats"

local score = Instance.new("IntValue")
 
score.Name = "Cash" -- Change "Cash" with Your Leaderstats Name
score.Value = 0
 
score.Parent = stats
stats.Parent = newPlayer
 
local score = Instance.new("IntValue")
	 
score.Name = "Energy" -- Change "Energy" with Your Leaderstats Name
score.Value = 0
 
score.Parent = stats
stats.Parent = newPlayer
end

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