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
wait(1)
end
end
end
game.Players.PlayerAdded:Connect(addJump)
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.
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
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 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.
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
Humanoid.Jumping:Connect(function(active)
Player:WaitForChild('leaderstats'):WaitForChild(JumpLeaderstatName).Value += 1
end)