Insert the Script into the brick from the BasicObjects menu in studio
Insert your SpotLight into the brick from the BasicObjects menu in studio
Insert a ClickDetectorinto the brick from the BasicObjects menu in studio
** View > Basic Objects, if you can't see the menu**
Make a table for our admins list.
local admins = { azarth = true, elitegamingchicken = true, player1 = true}
I like using dictionaries, since you don't have to loop through them to find a name.
Direct your variable to the ClickDetector and another to the light
local click = script.Parent.ClickDetector
local light = script.Parent.SpotLight
Use the MouseClickevent to detect clicks. This event returns the player who clicked it, so we can use that to check if they're in our admins table.
click.MouseClick:connect(function(player_who_clicked)
if admins[player_who_clicked.Name:lower()] then
if light.Brightness > 0 then
light.Brightness = 0
else
light.Brightness = 10
end
end
end)
Now, all together.
local admins = { azarth = true, elitegamingchicken = true, player1 = true}
local light = script.Parent.SpotLight
local click = script.Parent.ClickDetector
click.MouseClick:connect(function(player_who_clicked)
if admins[player_who_clicked.Name:lower()] then
print(player_who_clicked.Name.. " is in the admins table!")
if light.Brightness > 0 then
print("Turn the light off")
light.Brightness = 0
else
print("Turn the light on")
light.Brightness = 10
end
end
end)
1 comment
Hi im still struggling could you explain it a bit more detailed?