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

How to disable the Jumping while inside a vehicle(Drive seat)?

--LocalScript
script.Parent.Touched:Connect(function()

if script.Parent.Occupant then

game.Players.LocalPlayer.Character.Humanoid.JumpPower=0

end

end)
--The LocalScript is inisde the VehicleSeat

2 answers

✓ Accepted answer

I assume you're trying to disable jumping on the vehicle seat so that the player can't escape the vehicle they're using. This is simple. What you did wrong was you used the Player service to do it however the Occupant property of a Vehicle Seat is their humanoid. According to the article for the Vehicle Seat, it states that the Occupant property is "The humanoid that is sitting in the seat", so we can just use the occupant property from there.

local Seat = script.Parent --We create a variable for the seat.
Seat.Touched:Connect(function() --Once a part touches the seat, it's probably the player.
    local Humanoid = Seat.Occupant --We get the humanoid of the person who is sitting on the seat.
    if Humanoid then --If the humanoid exists and not some other part we continue the code.
		Humanoid.JumpPower = 0 --We convert the humanoid's JumpPower property to zero so they can't press the space bar and escape the vehicle.
	end
end)

1 comment

0

Thanks the script is working(sometimes)

game.Players.LocalPlayer.Character.Humanoid.JumpPower = 0 u need a space before and after the equal

2 comments

0

You dont

0

Dude, you don't need the space lol

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