Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

8 comments

0

You should check if event occures because of the Jump value is false, or true

0

The Value is at 1

0

it's won't work

0

oh thank you I forgot to add check if Jump is true or not

0

can you edit the anwser ? It's will be more easier for me

0

@Komas19 ok

0

Won't work

0

@Komas19 ok try char.Humanoid.Jump instead of GetPropertyChangedSignal

This discussion is preserved as it was. New answers, comments, and votes are closed.