Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Leaderboard that tracks jumps?

Asked by 7 years ago

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

0
The easiest way would be making a leaderstats for your player called jump, and make a key down event (on space) that adds +1 or so to the stats Nikkulaos 229 — 7y
0
But then they can just spam the spacebar as many times as they would like without having to actually jump. TickTockTheory 106 — 7y

1 answer

Log in to vote
0
Answered by
awfulszn 394 Moderation Voter
7 years ago
Edited 7 years ago

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

Answer this question