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

How do i move a part with a button?

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?

1 comment

0

i have already made a button

1 answer

✓ Accepted answer

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

1 comment

0

thanks

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