I have a game where i want players to have a higher jump power everytime they jump but my script isn't working right. Can somebody help me? This is my script:
01 | local JumpPower = 50 |
02 | local Player = script.Parent |
03 |
04 | while wait() do |
05 | if Player.Humanoid.jumping = = true then |
06 | repeat |
07 | JumpPower = JumpPower + 0.01 |
08 | Player.Humanoid.JumpPower = JumpPower |
09 | print (JumpPower) |
10 | until Player.Humanoid.jumping = = false |
11 | end |
12 | end |
But when i jump for some reason if Player.humanoid.jumping == true then
is always false.
This is the full script.
Hey check this link out. It is always more advisable to use an event than a loop. The way you can implement this is thus:
1 | player.Character.Humanoid.StateChanged:Connect( function (oldState, newState) |
2 |
3 | -- if newState is jumping then go forward otherwise do nothing |
4 |
5 | end ) |
Hope this helps and have a great day scripting!
Make a KeyDown Event with the Space Key, and in the event do what you want it to do if it's pressed.
01 | local JumpPower = 50 |
02 | local Character = script.Parent |
03 |
04 | Character.Humanoid.Jumping:Connect( function (active) -- parameter is if they're still jumping |
05 | repeat |
06 | JumpPower = JumpPower + 0.01 |
07 | Character.Humanoid.JumpPower = JumpPower |
08 | print (JumpPower) |
09 | until not active -- repeat until stop jumping |
10 | end ) |