Hi all, complete scripting newbie here, just trying to create a simple if else switch as my first test script, but the MouseClick only fires the 'OpenPortal' function. I am so new to this I'd imagine the solution is very simple but I'd appreciate any help!
local DoorCenter = script.Parent.DoorCenter
local DoorSwitch = script.Parent.DoorSwitch
local DoorClicker = script.Parent.DoorSwitch.ClickDetector
local function OpenPortal()
DoorCenter.CanCollide = false
DoorCenter.Transparency = 0.75
DoorCenter.BrickColor = BrickColor.Green()
print ("Door opened")
end
local function ClosePortal()
DoorCenter.CanCollide = true
DoorCenter.Transparency = 0
DoorCenter.BrickColor = BrickColor.Red()
print ("Door closed")
end
if DoorCenter.CanCollide == false then
DoorClicker.MouseClick:connect(ClosePortal)
else
DoorClicker.MouseClick:connect(OpenPortal)
end

1 comment
Thank you for the example and solution, this is great help. I see what I did.