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.
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)