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

how to define a speed of a vechile seat?

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

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

1 answer

✓ Accepted answer

#####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

2 comments

1

GOULSTEM IS BACK !

0

;D

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