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

How can I make this script update without a while true loop?

game.Players.PlayerAdded:Connect(function(player)

	local leaderstats = Instance.new('Model')
	leaderstats.Name = 'leaderstats'
	leaderstats.Parent = player
	local JumpPower = Instance.new('IntValue')
	local char = player.Character or player.CharacterAdded:Wait()
    local hum = char.Humanoid
	JumpPower.Value= 0 + hum.JumpPower
	JumpPower.Parent=leaderstats
	JumpPower.Name='Score'
	
	
	end)

How can I make this script update JumpPower.Value without a while true loop?

1 comment

0

You could use an event?

1 answer

✓ Accepted answer

Use humanoid.Changed:Connect(function() ... end) you can see more here: Roblox Wiki - Changed

Here is a example:

workspace.Baseplate.Changed:Connect(function()
	print("Baseplate changed!")
end)

Here is your fixed script:

game.Players.PlayerAdded:Connect(function(player)

    local leaderstats = Instance.new('Model')
    leaderstats.Name = 'leaderstats'
    leaderstats.Parent = player
    local JumpPower = Instance.new('IntValue')
    local char = player.Character or player.CharacterAdded:Wait()
    local hum = char.Humanoid
    JumpPower.Value= hum.JumpPower
    JumpPower.Parent=leaderstats
    JumpPower.Name='Score'
    hum.Changed:Connect(function()
	JumpPower.Value = hum.JumpPower
    end)
end)

Hope it helped :D

Errors? tell-me on comments.

5 comments

0

The leaderboard still doesn't update.

0

You changed the humanoid jump with server?

0

why use 0 + hum.JumpPower instead of just hum.JumPower? 0 + x = x

0

I used a local script. I wanted to increase jump power when the player pressed space.

0

Use ServerScript for change the value, or use RemoteEvents.

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