I am right now trying to make it so when I click a button, I have iron bars that will come up, but I do not know how to perform it, I have the script to make it so the iron bars move up.

local part = script.Parent

for i = 1,10 do part.Position = part.Position + Vector3.new(0,.5,0) wait(.3) end

But I do not know how to make it so when I click a button, it performs the action to all of the blocks I want it to. Anyone able to help me out with a script that may work?

11 comments

0

I would suggest to use TweenService instead of a for loop for moving parts, and moving via vectors is susceptible to collision with other objects, so you should use CFrame instead.

0

I found the script above on a YouTube video, so I have basically no experience with scripting, so I would not know how to preform any of that. Can you give me a script or dumb it down so I can understand it?

0

We dont just write scripts for people here, you have to at least attempt it yourself first, ill link you to a wiki that would help you: https://www.robloxdev.com/api-reference/event/ClickDetector/MouseClick

0

Ok, so if I understand this right, the Workspace.Part.ClickDetector.MouseClick:connect(function(playerWhoClicked) print("Part was clicked by: " .. playerWhoClicked.Name) end) Fires something once it is clicked, but what I want to do is not just fire one thing, I want to fire multiple. How would I do that.

0

then just add whatever you want to fire inside the function, if you want to move 2 iron bars after clicking it, write 1 line of code each for each iron bar in the function

0

a function doest just do one thing, it can do multiple things at a time if you want it to

0

How would I be able to specify what part I want to move? This is my script ATM. local part = script.Parent for i = 1,50 do part.Position = part.Position + Vector3.new(0,.1,0) wait(.1) end

0

you already specified the part with your part = script.Parent

0

I think you should read up on for loops and assigning variables on the roblox wiki first, it should help get you started

0

Ok I'll read up, thanks

0

Ok I'm trying to work this out, so I'm trying "workspace.button.ClickDetector.MouseClick:connect(function(playerWhoClicked) local part = script.Parent for i = 1,50 do workspace.bar1.Position = workspace.bar1.Position + Vector3.new(0,.1,0) wait(.1) end end)" And for some reason it is not working