I want to make a leaderboard that tracks the amount of times you jump. I've tried everything to make it but i can't figure it out. help please
Make this a server script inside of ServerScriptService
game.Players.PlayerAdded:Connect(function(plr) -- Get the player when they join local leaderstats = Instance.new('IntValue') -- Create a new int value leaderstats.Name = 'leaderstats' leaderstats.Parent = plr -- Parent the IntValue to the player local jumps = Instance.new('IntValue') -- Create another intvalue jumps.Name = 'Jumps' jumps.Parent = leaderstats -- Parent this IntValue to leaderstats jumps.Value = 0 end)
Make this a localscript in somewhere like StarterGui
local player = game.Players.LocalPlayer -- Get the player local char = player.Character or player.CharacterAdded:Wait() -- Get the character local leaderstats = player:WaitForChild("leaderstats") -- Find leaderstats in the player local jumps = leaderstats:WaitForChild("Jumps") -- Find jumps in leaderstats local db = false -- A debounce to stop the function running more than once while jumping. char.Humanoid.Changed:Connect(function() -- If any Humanoid properties are changed then this function will run if char.Humanoid.Jump == true and db == false then -- If the player jumped then... db = true jumps.Value = jumps.Value + 1 -- ... add 1 onto the players jump value. wait(0.5) db = false end end)