hello I can not create my leaderstats can tell me I envy that there is cash and Energy when I try it makes me rebight and coin?
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
game.Players.ChildAdded:connect(onPlayerEntered)
You don't need a calling 'function' just connect the PlayerAdded
to a function.
Why are you storing all your values in an int value?
Before we start, put the following code into Script and parent the Script to ServerScriptServer
game.Players.PlayerAdded:Connect(function(client) -- when a Player is added to the Players service this event will fire which is connected to a function and will run the following code local leaderStats = Instance.new("Folder", client) -- creating an instance and that instance is a folder which will be the parent of the Player that got added to the Players service leaderStats.Name = "leaderstats" -- not naming it will result in it not working. local score = Instance.new("IntValue", leaderStats) -- creating an instance and that instance is a Int value aka integer value and set the parent to the leaderstats score.Name = "Score" -- naming it to score. If you don't name it will be named 'Value' local energy = Instance.new("IntValue", leaderStats) -- same as how the score integer value was created energy.Name = "Energy" -- naming it end)