I'm completely new to coding, I wanted to know if it's possible to turn on a spotlight by having a brick opaque, and if so, how do I do it.
Let's say the part's name is LightPart.
Do the following.
while true do if game.Workspace.LightPart.Transparency == 1 then -- Checks if it's Transparent. game.Workspace.LightPart.SpotLight.Enabled = true -- If it is, it turns the SpotLight on. wait(1) -- One secound before it checks again. end
This will turn the SpotLight on if the part's Transparency is 1.
The while true do
tells the game to always check if the part is transparent or not.
if game.Workspace.LightPart.Transparency == 1 then
Is basically telling the game, "Is this Transparent or not?".
game.Workspace.LightPart.SpotLight.Enabled = true
is changing the value Enabled
(Turning it on.) to true.
wait(1)
is how long it's going to wait before it checks again. In this script, it's 1 second.
end
is the end of the while true do
in the script.
I hope this helped you understand coding a bit more.
I highly advise taking a look at https://developer.roblox.com/
. A lot of helpful information can be found there.