Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My function is not running when calling?

Asked by 7 years ago
Edited 7 years ago

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.

0
This is in a Local Script? OldPalHappy 1477 — 7y
0
Yes. hermosavida 6 — 7y
0
Line 6 isn't necessary... TheeDeathCaster 2368 — 7y
0
That was just me tryna figure out how to make it work. hermosavida 6 — 7y

2 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

don't forget to put local before function

Ad
Log in to vote
0
Answered by 7 years ago

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

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 Astrogue 75 — 7y

Answer this question