Script not working, help?

It’s a simple script, wich is why i’m confused, its a simple turn on and off screen tv, but depending on a boolvalue, the screen will show a diffrent decal.

It’s simple, but its not working at all, and i’m not sure what the problem is.

It originally was a proximitypront, with e as the button to hold to turn it on. But it didn’t work, so i tried changing things to work as a clickable button, but still doesn’t work.

local screen = script.Parent.Tela
local button = script.Parent.Botao
local creepy = script.Parent.Creepy --this is a boolvalue.
local turnedon = screen.Ligado -- this is a boolvalue
local cef = screen.Creepyef
local cbi = screen.Creepybi -- this, and the one above is a decal for the screen.

function Ligoutv()
	if creepy == false and turnedon.Value == false then
		screen.PointLight.Enabled = true
		turnedon.Value = true
		screen.Decal.Transparency = 0
		print("turned on, without scary decal.")
	elseif creepy == false and turnedon.Value == true then
		screen.PointLight.Enabled = false
		turnedon.Value = false
		screen.Decal.Transparency = 1
		print("turned off.")
	elseif creepy == true and turnedon.Value == false then
		screen.PointLight.Enabled = true
		turnedon.Value = true
		cef.Transparency = 0.5
		cbi.Transparency = 0.5
		print("turned on, but creepy.")
	end
end
button.ClickDetector.MouseClick:Connect(Ligoutv())

in the output, it says that its attempting to call a nil value… and thats the error that i’m not sure what i’m supposed to do, pls help.

This is the problem, you have to write the function name, not call it.
Change it to:

button.ClickDetector.MouseClick:Connect(Ligoutv)
2 Likes

still not working… what should i do?

1 Like

Then add some prints to check when the error starts

 -- Example
Code 1
print("yes")
Code 2
print("yes2")
Code 3
print("yes3")
1 Like

Can you show me output? It’ll be good.

there’s already some prints showing if it happened, idk where to put more prints .3.
but i’ll try

1 Like

i’ll also take some screenshots of that -w-

ok so:
Screenshot_215
here’s the new script, with the prints, and
here’s the output of that:

What is creepy? if it is a BoolValue instance then you should do in your conditions creepy.Value.

Your code runs right but the conditions seems to cause the problem, check which values are in your conditions because an instance in a condition will be always true
Also do you know what EmptyScriptAdder is? or is it your script name?

1 Like

the name of the script is just script

its working ^^ ty so much my friend