A disable jump script not working on seats

Hi! I’m currently trying to make it so when a player goes through a part this script executes:

local pad = script.Parent

local function HighJump(part)
local player = game.Players:GetPlayerFromCharacter(part.parent)
if player then
part.parent.Humanoid.JumpPower = 0
end
end

pad.Touched:Connect(HighJump)

Although, the player is seated inside of a vehicle while the part is there and it doesn’t seem to detect them or execute the script to disable them from jumping.

How would I fix this?

Thanks!

1 Like

You could try doing part.Parent.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)

(Basically doesn’t let the Humanoid enter that state anymore.)

1 Like

it should be part.Parent not part.parent

1 Like

I tried this and they’re still able to jump out. (When they’re not in the seat and walk through it, the script works.)

1 Like

local pad = script.Parent

local function HighJump(part)

local player = game.Players:GetPlayerFromCharacter(part.parent)

if player then

part.Parent.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)

end
end

pad.Touched:Connect(HighJump)

I tried this script, nothing (It doesn’t work in/out of seats)

parent is actually works, but it is deprecated in favor of Parent

1 Like

local pad = script.Parent

local function HighJump(part)

local player = game.Players:GetPlayerFromCharacter(part.parent)

if player then

part.Parent.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)

end
end

pad.Touched:Connect(HighJump)

I managed to get this script to kinda work but now I’m getting

"Humanoid is not a valid member of Accessory "

local pad = script.Parent

local function HighJump(part)
if part.Parent:FindFirstChild(“Humanoid”) then

local player = game.Players:GetPlayerFromCharacter(part.parent)

if player then

part.Parent.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)

end
end
end

pad.Touched:Connect(HighJump)

That should fix your problem.

Hi! I put it inside of a local script within the part:

Nothing seems to be happening (no errors either.)

Don’t use a local script. The touched function only works in regular scripts.

1 Like

Localscripts only work when parented under a tool, a starterPlayer container, or a playerGui descendant. However, why is the touched event being used here? If you just want jump to not work, you can use the seat’s Occupant property with GetPropertyChangedSignal().
Code snippet:

Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
    if Seat.Occupant then
        Seat.Occupant.JumpPower = 0
    end
end)

@MegaFireball0 Touched events work fine on the client, but most developers wouldn’t recommend using them as they can be exploited, since the client sends the signal that a part was touched.

Heya! I appreciate the insight and information, but the touched event needs to be used to ensure players can jump again while getting off of the ride… I’m unsure on how I’d do that using the functions/scripts provided by you.

You can have a function so that once the ride is at the end (use a timer, or touchEvent with a small trigger that is on the track or whatever you’re using), you restore the humanoid jump power to the default (50)

Create a script into ServerScriptService. Then put this inside:

game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(character)
while true do
wait(1)
if character.Sit == false then
part.Parent.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
end
end)
end)

@Styre_x, I just tested it and touched events are a pain if your using the client side.