Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My function is not running when calling?

I'm trying to make a lamp that turns off during the day. I'm also trying to make it compatible with FE. I can't test it when I cannot run the function.

function fireServ()
		script.Parent:WaitForChild("ChangeLight"):FireServer()
		print("Fired!")
	end

if 1 + 1 == 2 then
	fireServ()
end

The output logs say nothing about there being error nor printing, "Fired!". I don't know what I'm doing wrong?

edit ; It's in a LocalScript if that helps.

4 comments

0

This is in a Local Script?

0

Yes.

0

Line 6 isn't necessary...

0

That was just me tryna figure out how to make it work.

2 answers

don't forget to put local before function

To do this, use the Script, not LocalScript

function fireServ()
       	script.Parent:WaitForChild("ChangeLight"):FireServer()
        print("Fired!")
end

local s = 1
if s + 1 == 2 then
    fireServ()
end

1 comment

0

If not working, then the problem is in the line: script.Parent:WaitForChild("ChangeLight"):FireServer() because if you replace it on the workspace.Baseplate.Transparency = 1 then everything works fine

This discussion is preserved as it was. New answers, comments, and votes are closed.