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

How can i dectect Vehicle Seat movement to call a function???

Asked by
NexeusX 137
8 years ago

I want to be able to have a script that will call a function when the player on the vehicle seat moves forward left right and back etc...but i don't know how make a script detect a vehicle seats direction the player wants it to go how can i do this? sorry if question isnt clear

0
Ok i see i got a clearer idea now...i use the throttle and steer properties and use a script to detect them, which then i can call a function thanks DevSean NexeusX 137 — 8y

1 answer

Log in to vote
0
Answered by
davness 376 Moderation Voter
8 years ago

The easiest. VeichleSeatinstance owns two properies, Steer and Throttle. Steer is related to the side movement. 1 means right, 0 means no direction and -1 means left Throttle is related to the "engine" movement. 1 means forwards, 0 means no engine work and -1 means reverse work (backwards)

So, you may use Changed() event to determine whatever of the properties is being changed.

game.Workspace.Car.VeichleSeat.Changed:connect(function(p)
    if p == "Throttle" then
        local val = game.Workspace.Car.VeichleSeat[p]
        --Do stuff
    elseif if p == "Throttle" then
        local val = game.Workspace.Car.VeichleSeat[p]
        --Do stuff
    else return end -- does nothing
end)
Ad

Answer this question