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

Attempt to call global?

Asked by 10 years ago
01currentTemp=game.Workspace:WaitForChild("TemperatureValue")
02AlarmMinorS=game.Workspace.AlarmMinor
03AlarmMajorS=game.Workspace.AlarmMajor
04MainframeStatus=game.Workspace.MainframeStatus.SurfaceGui.TextLabel
05 
06function alarmMinor()
07    if currentTemp.Value >= 700 then
08        AlarmMinorS:Play()
09        AlarmMajorS:Stop()
10        --
11        MainframeStatus.Text = "LavaBlast://Core_Status/Issue"
12        MainframeStatus.TextColor3 = Color3.new(255, 85, 0)
13        --
14        local firethree = workspace.Mainframe_Status_Fire_Parts:GetChildren()
15        for i = 1, #firethree do
View all 82 lines...

And this is the error:

121:10:17.277 - Workspace.Meltdown Detector:79: attempt to call global 'normalTemperature' (a nil value)
221:10:17.277 - Stack Begin
321:10:17.277 - Script 'Workspace.Meltdown Detector', Line 79
421:10:17.278 - Stack End
5-- Also line 79 is "normalTemperature()"

I don't know what is wrong. Please help asap! :)

1
Can you give us the full script? It looks like either normalTemperature, alarmMinor, or alarmMajor is not defined. Merely 2122 — 10y

2 answers

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

Merely is correct. Based on the positioning of your ends, the second function is only defined after the first is called, and the third only after the second! Also, there appears to be an extra 'end'.

This is very easy to see if you properly indent and un-indent your lines:

01--snip
02 
03function alarmMinor()
04    if currentTemp.Value >= 700 then
05        --snip
06        for i = 1, #firethree do
07            --snip
08            for i = 1, #mainframelights do
09                --snip
10            end
11        end
12    end
13 
14    function alarmMajor()
15        if currentTemp.Value >= 1000 then
View all 42 lines...
1
Ahh, I see where I went wrong :) Thank you. I shall give you the best answer because you gave me the full script. Sorry Merely! :p WelpNathan 307 — 10y
0
Merely was merely trying to point you in the general direction of the answer. Like I said, it isn't obvious until you fix the indentation. adark 5487 — 10y
0
Yeah :) WelpNathan 307 — 10y
Ad
Log in to vote
2
Answered by
Merely 2122 Moderation Voter Community Moderator
10 years ago

That error occurs when you try to call a function that you haven't defined.

For example:

1testFunction()

15:31:01.765 - testFunction():1: attempt to call global 'testFunction' (a nil value)

1
I am sure I defined it. I just edited my script to show it all. WelpNathan 307 — 10y
0
Ahh. Thank you! WelpNathan 307 — 10y

Answer this question