So, I have been working on this script for a while:
local elevator = game.Workspace.Elevator --shorter for typing purposes
--this is a short for loop to find the first Part in the elevator
for i, v in pairs(elevator:GetChildren()) do
if v:IsA("BasePart") then --all part types inherit from basepart therefore they're all baseparts
elevator.PrimaryPart = elevator.door2 -- set the primary part
break -- break statement will stop the for loop and go back up scope
end
end
function onClicked()
elevator.door2.CanCollide = true
for i = 1, 20, 1 do
elevator.door2.Transparency = elevator.door2.Transparency - .05
wait(.05)
end
for i = 1, 800 do
elevator:SetPrimaryPartCFrame(elevator:GetPrimaryPartCFrame() * CFrame.new(0, -0.1, 0))
wait(.01)
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
How can I make it so that this script runs when a dialog is clicked? And, what should this script's parent be (the dialog? anything? Workspace?)

3 comments
Where would I input my actually function for that though? I am not used to calling functions the way that you did.
On line 5 you can see that I call your onClicked function
Thanks very much for the help, but I am asking where I should add your script, to mine? Should I put it after everything, inside of my function, or before everything? I'm relatively new to scripting, so I need all the help I can get. Sorry for the trouble.