There is an error in this leaderstats script

I want to do is that when a player jumps, he is put in the Leaderstats
but there is a mistake.

local function addJump(Player)
	local humanoid = game.Players.LocalPlayer.FindFirstChildWhichIsA("Humanoid")
	if humanoid then
		if humanoid.Jump then
			humanoid.Jump = humanoid.Jump.Value + 1

First of all, you are trying to find the humanoid inside of the player instance itself instead of the character. You also should use a character added function for this. Also, you can use get property changed signal on the humanoid’s jump value in order to see this.

You can use Humanoid.Jumping event

There are a few things wrong with your code.
First of all,
humanoid.Jump = humanoid.Jump.Value + 1
this doesn’t make much sense as Humanoid.Jump is a boolean, and humanoid.Jump is a property and you can’t really instance a numbervalue or integer value to it
Assuming it is a server script, game.Players.LocalPlayers can only be used in localscript
This isn’t all the mistakes in the script though, look at what the others have to say

1 Like

This code will only run once when a player joins.

First off instead of saying humanoid.Jump = humanoid.Jump.Value+1 you want to say humanoid.Jump.Value = humanoid.Jump.Value +1, also this will only run once when they join.

I think you can fix it using a LocalScript and a RemoteEvent

The humanoid’s Jump property is a boolean, not a value object.

I assumed he is trying to change an int value that is in the player called Jump whenever the player jumps. He also needs to use the Humanoid.Jump event.

u can change “if humanoid.Jump” to Humanoid.Jumping

-This is a example of the roblox help

      print("Jumping: ", isActive)

This would works

local Player = game.Players.PlayerAdded:Wait()`

local Character = Player.CharacterAdded:Wait()

local Humanoid = Character:FindFirstChild('Humanoid')

local JumpLeaderstatName = 'Jumps' --leaderstat name to change value when jumping


Player:WaitForChild('leaderstats'):WaitForChild(JumpLeaderstatName).Value += 1


another error of your script its LocalPlayer only can be called from the Client you can call it from the server using this:

local Player = game.Players.PlayerAdded:Wait()

Dont work Without or with the comma

in the code you have ` sign

1 Like