Hello People!
Kuro here, aka Immortxl from my past account.
I am currently learning how to script and was wondering if there are any scripters out there that could clear my confusions and answer my questions. I will be editing the questions as I further progress and will also leave my disxord here,
βΈΈ π΄πππππππ#0666
Current Question :
How do i assign 2 functions to a click detector, like, click once to open a door, and click again to close that door. Something like that.
Youβre supposed to substitute the function with other functions, besides the syntax is incorrectly written. Some of the code could be improved as this object is statically stuck in one place and cannot be changed without breaking its level away from its socket.
local object = script.Parent
local erm = game.SoundService
local debounce, isOpen
object.ClickDetector.MouseClick:Connect(function()
if debounce then
return
end
debounce = true
if not isOpen then
workspace.Level.Lever.Position = Vector3.new(618.4, 8.675, 35.525)
workspace.Level.Lever.Orientation = Vector3.new(0, 0, -30)
workspace.REDTEAM.Transparency = 1
workspace.REDTEAM.CanCollide = false
isOpen = true
else
workspace.Level.Lever.Position = Vector3.new(615.85, 8.675, 35.525)
workspace.Level.Lever.Orientation = Vector3.new(0, 0, 45)
workspace.REDTEAM.Transparency = 0
workspace.REDTEAM.CanCollide = true
isOpen = false
end
erm.Flick:Play()
wait(10)
debounce = false
end)
workspace is actually a global.
Statements are like A or B switches, use them wisely
Controls of the statements requires a boolean which reflects A or B gate
Positions are fixated and needs to be relative positions to X rather than constants