Hey! I’m relatively new to scripting [I’ve just learned extreme basics over scanning through other’s scripts, and I’m mainly a builder, so it’s a bit foreign to me.]
I’m currently trying to learn lua, and I’m working on a script that can open a door by making the parts transparent.
The script here is currently working, and I’m not having issues with it- However, I’m looking for a way to save time instead of constantly listing all parts.
I know there’s a thing called Getchildren, however I’m not completely sure how to use it. (Again, complete and total noobie.)
Script
local isOn = true
function on()
isOn = true
script.Parent.door1.CanCollide = true
script.Parent.door1.Transparency = 0
script.Parent.handle3.CanCollide = true
script.Parent.handle3.Transparency = 0
script.Parent.handle4.CanCollide = true
script.Parent.handle4.Transparency = 0
script.Parent.poster1.CanCollide = true
script.Parent.poster1.Transparency = 0
script.Parent.poster1.decal1.Transparency = 0
end
function off()
isOn = false
script.Parent.door1.CanCollide = false
script.Parent.door1.Transparency = 1
script.Parent.handle3.CanCollide = false
script.Parent.handle3.Transparency = 1
script.Parent.handle4.CanCollide = false
script.Parent.handle4.Transparency = 1
script.Parent.poster1.CanCollide = false
script.Parent.poster1.Transparency = 1
script.Parent.poster1.decal1.Transparency = 1
end
function onClicked()
if isOn == true then off() else on() end
end
script.Parent.door1.ClickDetector.MouseClick:connect(onClicked)
on()
Really sorry about this !! I don’t want to be a bother at all, so I’m kinda scared to ask this because I know the answer’s going to be extremely simple, and I’ll probably look a bit dumb.
Any help would be appriciated though !!