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

How do i move a part with a button?

Asked by 5 years ago

I've made three parts https://gyazo.com/4d971ebdcba72624686f0ac22fb76e4b

and the middle one goes back and forth bettween the two other parts all the time. the script is

local start = game.Workspace.MovingModel.Start
local finish = game.Workspace.MovingModel.Finish
local bodyposition = game.Workspace.MovingModel.Platform.BodyPosition

while true do
   bodyposition.Position = start.Position
   wait(2)
   bodyposition.Position = finish.Position
   wait(2)
end

I want to be able to press a text button and the middle one goes back and forth once is that possible?

0
i have already made a button fnaticOlofMisterXd 2 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

You would make a function and bind it to TextButton.MouseButton1Click so something like this:

function onClick()
    bodyposition.Position = start.Position
    wait(2)
    bodyposition.Position = finish.Position
    wait(2)
end
TextButton.MouseButton1Click:Connect(onClick) -- remember when you are binding a function, you are **NOT** calling it, so don't use () instead just reference it
0
thanks fnaticOlofMisterXd 2 — 5y
Ad

Answer this question