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

How do I make a script detect the status of a SeatPart?

I'm trying to make a script that can detect the status of a vehicle through the SeatPart for a racing game. I've been trying to the best of my ability for the past few months, but nothing's been working. I think I'm on the right track with this one, but I could use a nudge in the right direction.

script.Parent.Touched:Connect(function(hit)
while true do
	if script.Parent.Humanoid.SeatPart.Steer == 1 then
		print("TurnRight")
	end
end
end)

1 answer

✓ Accepted answer

From what I've seen that your trying to do. Is to, detect if the steer of seat part is set to 1(right). But, it doesn't really work that way. The steer value of seat part is constantly reset to 0 unless stated otherwise. A good counteraction to this is to, detect when the player is in the seat...aka.(SeatPart.Occupant). If they are in the seat, take input from that player, aka.(UserInputService). When that player, presses "A" or "D", set the steer of seat part to 1(right) or -1(left), then your current script will be able to detect when it is set to 1. Remember, you also have SeatPart.Throttle, where you can set 1(forward, "W") and -1(reverse, "S").

Hope This Helped!

1 comment

0

Sorry for the late response, that makes sense too, I was hoping to avoid writing separate scripts for joystick and keyboard support, but that'll just come later I suppose.

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