I need help. Script doesn't work for unknown to me reason

I want to start with the fact that I started attempting to write scripts less than a week ago, so I expect that this probably happened due to the fact I incorrectly did something, didn’t notice something small or big, or there could be some another issue or my own mistake I’m not aware of.
So, I wanted to script lamp enabling once a boolvalue is checked. The light part would change material to neon and surfacelight in it would get enabled and angle would go from one value to another via tween.
The issue is that nothing changes; not a single property.
Output doesn’t say anything and I do not understand whats wrong.
This is the script
image

Sorry in case its something simple that I didn’t notice myself.

1 Like

You’re only checking if the A1Lamp1Power is true 1 time when the script loads in. Use GetPropertyChangedSignal(), which fires every time the specified property changes in an instance:

values.A1Lamp1Power:GetPropertyChangedSignal("Value"):Connect(function()
    enable()
end

Thank you. I also noticed a few more of my own mistakes that also prevented my script from working.

Make sure to set their reply as the solution if it is what you needed fixed!!

Oh well I think I hit heart instead of solution.

values.A1Lamp1Power.Changed:Connect(function(Value)
	if Value then
		--Do code.
		enable()
	end
end

Use the ‘Changed’ event/signal for value objects.

Whoops, forgot to check the value.

Changed is for detecting any property change in the instance while GetPropertyChangedSignal() listens to one specific property. So in this case, GetPropertyChangedSignal() would be the best option to use.

That would normally be the case but since we’re working with value objects the ‘Changed’ event/signal behaves differently.
https://developer.roblox.com/en-us/api-reference/event/IntValue/Changed
It only fires when the ‘Value’ property changes and it passes its new value to any connected callback functions.

Oh, it seems like my understanding of Changed was wrong. Thanks for letting me know though.