Im trying to make a script where when the parts velocity is 15.904 or above, that the player who got hit by the part sits, and i noticed when the velocity is under that number after it was above… the player still sits when touched, i don’t know how to fix this, can anyone help me?
here is my script:
local trippart = script.Parent
local car1 = script.Parent
function checkVelocity()
while true do
wait(0.1)
local velocity = car1.Velocity.Magnitude
if velocity >= 15.904 then
trippart.Touched:Connect(function(part)
if part.Parent:FindFirstChild("Humanoid")then
part.Parent.Humanoid.Sit = true
end
end)
end
end
end
while true do
checkVelocity()
end
local tripPart = script.Parent
tripPart.Touched:Connect(function(player)
if player.Parent:FindFirstChild("Humanoid") then
local velocity = tripPart.Velocity
if velocity >= 15.904 then
local humanoid = player.Parent:WaitForChild("Humanoid")
humanoid.Sit = true
wait() --however long the player should wait before automatically standing
humanoid.Sit = false
end
end
end)
The Touched:Connect function doesn’t trigger when the player is sitting. Therefore, you might want to try using the SeatPart property of the Humanoid object instead of Touched:Connect