hello, i need help on making a script that makes it when u go inside of a part it make the player levitate by making them spam the jump button, i have everything done i just dont know how to make it so it will make them infinitely jump.
script.Parent.Touched:Connect(function(BodyPart)
if BodyPart.Parent:FindFirstChild("HumanoidRootPart") then
BodyPart.Parent.Humanoid.Jump = true
end
end)
while Condition do -- The Condition is so if you ever want to disable it
task.wait(.1) -- waits .1 seconds
if not Humanoid.Jump then -- Humanoid.Jump is false or nil
Humanoid.Jump = true -- Forces Player to jump
end
end
local part = script.Parent
local JumpingTime = nil
part.Touched:Connect(function(hit)
local h = hit
if h then
local findPlayer = h.Parent:FindFirstChild("HumanoidRootPart")
if findPlayer then
h.Parent.Humanoid.Jump = true
if JumpingTime == nil then
warn("JumpingTime is nil")
else
print("Waiting.")
task.wait(JumpingTime)
h.Parent.Humanoid.Jump = false
end
end
end
end
end
end)
Humanoid.Jump will only make the player jump when it is on the ground so using Humanoid:ChangeState(Enum.HumanoidStateType.Jumping) will apply no matter what
if you are looking for it to jump each time it hits the ground
use Runservice and for each frame set the jump to true.