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?)
Dialogs have a DialogChoiceSelected event that is triggered whenever a player clicks on a dialog choice under that Dialog.
http://wiki.roblox.com/index.php?title=API:Class/Dialog/DialogChoiceSelected
So if you make the script's parent the dialog, you could just write code like this:
local dialog = script.Parent dialog.DialogChoiceSelected:connect(function(player, dialogChoice) if (dialogChoice.Name == "Name of your dialog choice goes here") then onClicked() end end)