How to make a part that makes a player infinitely jump

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)

any help is appreciated <3

1 Like

You can just do this:

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

Jump doesn’t make the Player Levitate, it just forces them to jump, you would be looking at Velocity, Gravity or Mover Constraints

1 Like

I’ve tried using velocity but it was really buggy.

1 Like

Try this:

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)
1 Like

If you want the player to levitate, make a animation and make the player rise with scripts.

You should Probably handle this on the Client as Player Movements are Replicated from the Client to the Server.

2 Likes

I know what you did. You also know what you did.

This looks messy ngl

    local h = hit
       if h then
          local findPlayer = h.Parent:FindFirstChild("HumanoidRootPart")
             if findPlayer then

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.