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

how to define a speed of a vechile seat?

Asked by
hokyboy 270 Moderation Voter
5 years ago

how to get the speed of a seat into a gui i have this

script.Parent.Text = game.Workspace.VehicleSeat.Speed

1 answer

Log in to vote
2
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
5 years ago
Edited 5 years ago
Issues
  • Speed is not a property of VehicleSeat objects. What you should be referencing is Velocity.

  • Consider when the property changes, rather than just updating the gui once. You can do this with the Changed event.


Note :: GUI code should always be in a LocalScript. There is no reason for the server to handle the client's UI.

Code
--Use WaitForChild since client code may load faster than the server
local vehicle = workspace:WaitForChild("VehicleSeat")

--Use `Velocity`
function match()
    --Index the magnitude member to get the length of the vector,
    --rather than the axis values
    script.Parent.Text = vehicle.Velocity.magnitude
end

match() --Match initially
vehicle.Changed:Connect(match) --Match upon changing
1
GOULSTEM IS BACK ! User#19524 175 — 5y
0
;D Goulstem 8144 — 5y
Ad

Answer this question