Hey! I'm currently stuck in the programming of my game because of a script that I have to make: the goal is that when I click on the button I created, the character starts to jump and I have to wait for it to hit the ground before I can click again. I have already managed to program the script to make the character jump but I can't manage to do the one that allows me to wait for the character to touch the ground before being able to click again. Here is the script:
-- Parameters
local WAIT_TIME = .5
-- Services
Player = game:GetService("Players")
local button = script.Parent
local canActivate = true
local function playerJump()
if canActivate then
canActivate = false
local localPlayer = Player.LocalPlayer
local character = localPlayer.Character
local Humanoid = character:WaitForChild("Humanoid")
local oldJumpPower = Humanoid.JumpPower
Humanoid.JumpPower = 1
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
Humanoid.JumpPower = oldJumpPower
task.wait(WAIT_TIME)
canActivate = true
end
end
button.Activated:Connect(playerJump)
I hope that someone could help me! Thanks in advance! Belox.

2 comments
Maybe 0.5 seconds is a bit short of time to notice if the debounce works or not, try to make it into a bigger wait number, like 5, to make sure the debounce works fine
My script allows that, each time I click on the jump button, the jump strength increases by 1, which means that if I put 5 for example, after a while the button will not work because I would be in the air.