Hello, I need help adding a second leaderstats named “Coins” appear on the leaderboard along with the first one which is “Jumps”. I’m by no means an expert scripter, I tried to do something but it just renames the “Jumps” leaderstats and doesn’t make the script work.
Below I’m leaving the original script:
local DataStoreService = game:GetService("DataStoreService")
local jumpsDatastore = DataStoreService:GetDataStore("JumpsDataStore")
local function loadData(datastore, key)
local success, data = pcall(function()
return datastore:GetAsync(key)
end)
return data
end
local function saveData(datastore, key, value)
local success, err = pcall(function()
datastore:SetAsync(key, value)
end)
if err then print(err) end
end
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local jumpCount = Instance.new("IntValue")
jumpCount.Name = "Jumps"
jumpCount.Parent = leaderstats
jumpCount.Value = loadData(jumpsDatastore, player.UserId) or 0
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
local debounce = true
humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
if debounce == true then
debounce = false
if humanoid.Jump == true then
jumpCount.Value = jumpCount.Value + 1
end
wait(0.2)
debounce = true
end
end)
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
local jumps = player.leaderstats.Jumps
saveData(jumpsDatastore, player.UserId, jumps.Value)
end)
Thanks in advance to anyone trying to help