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

How do I use BodyVelocity?

Asked by
Hakupa 0
9 years ago

num = 0 button = script.Parent engine = button.Parent.Parent.Engine.BodyVelocity

function normalspeed()

button.BrickColor = BrickColor.new(37) engine.velocity = Vector3.new(0,0,60) end

function lowspeed() button.BrickColor = BrickColor.new(24) engine.velocity = Vector3.new(0,0,35)
end

function brake() button.BrickColor = BrickColor.new(21) engine.velocity = Vector3.new(0,0,0)
end

button.ClickDetector.MouseClick:connect(function() num = num + 1 if num == 1 then normalspeed() elseif num == 2 then lowspeed() elseif num == 3 then brake() num = 0 end end)

I just started experimenting with body movers today because I am building a train. My goal is to make script.Parent.Parent.Parent move at different speeds by changing BodyVelocity.velocity when script.Parent is clicked. The button changes color, but the train does not move in any direction at all. It is not anchored or anything, and it is lined up on the axis correctly, but there is still a problem. The output returns no errors, by the way. Could anyone solve my problem? Thanks!

0
Please edit your post to make the Lua code formatting right BlueTaslem 18071 — 9y
0
I keep trying to edit it, but the format won't show when I view the saved post. Hakupa 0 — 9y
0
There should be one bar of tildes (~~~~~) above the code, and one bar below (after). BlueTaslem 18071 — 9y

Answer this question