So, I've been working on the following 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 this script be performed when a DialogChoice/Dialog is selected? Rather than functioning onClicked, would it be something like DialogChoiceSelected?
You'd have to put this script under a Dialog instance directly, but you could do this:
local elevator = game.Workspace.Elevator --shorter for typing purposes 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 local d = script.Parent.DialogChoice1 --You'd have to make a DialogChoice instance named DialogChoice1 function onClicked(c, p) --Set this to accept 2 parameters, choice and player if c = d then 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 end script.Parent.DialogChoiceSelected:connect(onClicked())
I'm pretty sure this'd work, then. I hope, at least. Not sure, because I don't have the same workspace as you right now.