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

When i jump it won't add a jump in the leaderstats . How do i fix it ?

Asked by
Komas19 34
4 years ago

Help me please i want to create a simulator

while wait(.5) do
        local children = game.Players:GetChildren()
        for i = 1, #children do
            if children[i].Character ~= nil then
            local hum = children[i].Character.Humanoid
            hum.JumpPower = children[i].leaderstats.Jump.Value/3.12
            if game.Players.LocalPlayer.Character.Humanoid.Jump == true then
                game.Players.LocalPlayer.leaderstats.Jump.Value = game.Players.LocalPlayer.leaderstats.Jump.Value +1
            end
        end
    end
    end

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Don't use loop. Just detect when the player is jumping by using :GetPropertyChangedSignal()

use Players.PlayerAdded to get player and use Player.CharacterAdded to get player's character

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        local hum = char.Humanoid
        hum:GetPropertyChangedSignal("Jump"):Connect(function()
            if hum.Jump == true then
                plr.leaderstats.Jump.Value = plr.leaderstats.Jump.Value +1
                hum.JumpPower = plr.leaderstats.Jump.Value/3.12
            end
        end)
    end)
end)

Also change the script from LocalScript to ServerScript

0
You should check if event occures because of the Jump value is false, or true Spjureeedd 385 — 4y
0
The Value is at 1 Komas19 34 — 4y
0
it's won't work Komas19 34 — 4y
0
oh thank you I forgot to add check if Jump is true or not Mr_m12Ck53 105 — 4y
View all comments (4 more)
0
can you edit the anwser ? It's will be more easier for me Komas19 34 — 4y
0
@Komas19 ok Mr_m12Ck53 105 — 4y
0
Won't work Komas19 34 — 4y
0
@Komas19 ok try char.Humanoid.Jump instead of GetPropertyChangedSignal Mr_m12Ck53 105 — 4y
Ad

Answer this question