Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
--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

Log in to vote
0
Answered by
Mr_Unlucky 1085 Moderation Voter
5 years ago
Edited 5 years ago

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)
0
Thanks the script is working(sometimes) bostaffmanbulgaria1 89 — 5y
Ad
Log in to vote
-1
Answered by 5 years ago

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

0
You dont RBLX_Nat 18 — 5y
0
Dude, you don't need the space lol Mr_Unlucky 1085 — 5y

Answer this question