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

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

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by
Farsalis 369 Moderation Voter
4 years ago
Edited 4 years ago

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!

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. Superluigi2001 2 — 3y
Ad

Answer this question