How do i make leaderstat change on player's jump?

local Players = game.Players

Players.PlayerAdded:Connect(function(player)
	local character = player.Character or player.CharacterAdded:Wait()
	local Humanoid = character:WaitForChild("Humanoid")
	local leaderstatsFolder = Instance.new("Folder", player)
	leaderstatsFolder.Name = "leaderstats"
	
	local jumps = Instance.new("IntValue", leaderstatsFolder)
	jumps.Name = "Jumps"
	jumps.Value = math.random(5,20)
	if Humanoid.Jump == true then -- need some help here
		jumps.Value = jumps.Value - 1
	if jumps.Value <= 0 then
		player:Kick("You have ran out of jumps!")
		end
	end
end)
1 Like

There is a function jumprequest:connect(… ) but now I’m on mobile so you have to check this feature for yourself

This event is triggered when the player tries to jump.

could try this and see if it will detect it fast enough for true
this makes a connection to the jump property so when it changes fires this function which then does what you wrote to see if jumps true

Humanoid:GetPropertyChangedSignal('Jump'):Connect(function()
	if Humanoid.Jump then
		jumps.Value = jumps.Value - 1
		if jumps.Value <= 0 then
			player:Kick("You have ran out of jumps!")
		end		
	end
end)

Humanoid.StateChanged can also be used
And then check: local state = humanoid:GetState()
If state == Enum. HumanoidStateType.Jumping then…
I think it is more reliable.

try this

Humanoid.Jumping:Connect(function(IsJumping)
    if IsJumping Then
		jumps.Value = jumps.Value - 1
	if jumps.Value <= 0 then
		player:Kick("You have ran out of jumps!")
		end
	end
end)
1 Like