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
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