how to get the speed of a seat into a gui i have this
script.Parent.Text = game.Workspace.VehicleSeat.Speed
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.
01 | --Use WaitForChild since client code may load faster than the server |
02 | local vehicle = workspace:WaitForChild( "VehicleSeat" ) |
03 |
04 | --Use `Velocity` |
05 | function match() |
06 | --Index the magnitude member to get the length of the vector, |
07 | --rather than the axis values |
08 | script.Parent.Text = vehicle.Velocity.magnitude |
09 | end |
10 |
11 | match() --Match initially |
12 | vehicle.Changed:Connect(match) --Match upon changing |