I am trying to make a flashlight on and off system
I have correctly referenced everything and all the conditionals are in place. My only problem is that this part of my script does not change the value of these booleans. (if I add .Value it gives an attempt to index bool with .Value error. Here is the part that’s not working
local light = Switch.Parent["Light Model"]
local flare = light.LightFLare.Flare.Enabled
local source = light.LightSource.SpotLight.Enabled
if Switch.Value == true then
flare = false
source = false
Switch.Value =false
else
flare = true
source = true
Switch.Value = true
end
end)
Note: flare is a billboard GUI and source is a spotlight and switch is a bool value stored in the flashlight model
local light = Switch.Parent["Light Model"]
local flare = light.LightFLare.Flare
local source = light.LightSource.SpotLight
if Switch.Value == true then
flare.Enabled = false
source.Enabled = false
Switch.Value =false
else
flare.Enabled = true
source.Enabled = true
Switch.Value = true
end
end)
Because flare and source is defined to a value not a property
They are the enabled properties of the instances of the gui and the spotlight
yes but when you defined
local flare = light.LightFlare.Flare.Enabled
it set “flare” to a true or false, its not a direct reference to the actual property
When you do:
local variable = Instance.Property
You’re not holding a reference to the property; you’re just setting the value of the variable to what ever the value of the property is at the time. So doing:
variable = NewValue
wouldn’t change the actual property, just the value of the variable in memory.
Can you make a screenshot of the elements concerned because I do not know what it is