Script isn't triggering when Player Jumps

Hey Developers, I’m stuck again on another script problem. Let me explain, Basically Ive been trying to make a simulator game on Roblox. And I want to make it so where when a player Jumps, it’s triggers a the local script within the tool. When the game is launched, each player would be given a tool. When the player equips the tool and jumps it will add 1 to the leader stats. I know this isn’t the best explanation, but that’s besides the point. I need some help.

local player = game.LocalPlayer

script.Parent.Equipped:Connect(function()

player.Charecter.Humanoid.JumpPower = player.Charecter.Humanoid.JumpPower + player.JumpUPG.Value

end)

script.Parent.Unequipped:Connect(function()

player.Charecter.Humanoid.JumpPower = player.Charecter.Humanoid.JumpPower - player.JumpUPG.Value

end)

while wait(1) do

if player.Charecter.Humanoid.Jump == true then

player.leaderstats.JumpPower.Value = player.leaderstats.JumpPower.Value +1

end

end

you can’t add leaderstats on the client. send a remote to the server then do it on the server.

as @AC_Starmarine said, you can’t add leaderstats on the client, but after you change this to a script, instead of using wait and checking if they are jumping, use

humanoid.Jumping:Connect(function()
---add leaderstats
end)
1 Like

Also I forgot to mention, I followed a Youtube video to script this.

When was it released? It must be old before FE

The Video was released on 4th March 2021.

You didn’t spell character right. SMH

1 Like

Crap, thanks for helping. I completely forgot.

1 Like

Even if that fixes it, the leaderstats still need to be changed on the server and not the client or other people wont see your agians.

1 Like

Can you show how to, Im quite confused.

1 Like

Make a remote event in replicated storage. This is where items that can be accessed by the client and server go.
Here is a tutorial I found to help you.

1 Like

Ive already got a remote event, But the tutorial doesn’t help at all.

1 Like

If you know how to help me, please don’t hesitate to comment.

Just make the stats on the server i think he means?

You are gonna need to explain about “Charecter”…
Maybe it is the problem.

Ive already made the server script.

What do you mean? He didn’t make them on the client, he is trying to access them. This is a basic stats script.

I’m pretty sure he’s aware, it’s just that the issue here is with client-server replication

If you change the Value from the client, it will only be visible & accessible to your side

If you change it from the Server however, it can be accessed from anywhere since it’s being added globally

Also there’s a much better approach of detecting when the Character will jump instead of having to use a while wait(1) do loop

local player = game.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

script.Parent.Equipped:Connect(function()
    Humanoid.JumpPower = player.Charecter.Humanoid.JumpPower + player.JumpUPG.Value
end)

script.Parent.Unequipped:Connect(function()
    Humanoid.JumpPower = player.Charecter.Humanoid.JumpPower - player.JumpUPG.Value
end)

Humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
    if Humanoid.Jump == true then
        --Do stuff here
    end
end)
1 Like

try using humanoid.StateChanged instead of a while loop

OHHHHHHHH that’s probably why like EVERY SINGLE ONE of my datastore scripts don’t work!! Tysm!