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

Attempt to call global?

currentTemp=game.Workspace:WaitForChild("TemperatureValue")
AlarmMinorS=game.Workspace.AlarmMinor
AlarmMajorS=game.Workspace.AlarmMajor
MainframeStatus=game.Workspace.MainframeStatus.SurfaceGui.TextLabel

function alarmMinor()
	if currentTemp.Value >= 700 then
		AlarmMinorS:Play()
		AlarmMajorS:Stop()
		--
		MainframeStatus.Text = "LavaBlast://Core_Status/Issue"
		MainframeStatus.TextColor3 = Color3.new(255, 85, 0)
		--
		local firethree = workspace.Mainframe_Status_Fire_Parts:GetChildren()
		for i = 1, #firethree do
    	firethree[i].Fire.Enabled = false
		--
		local mainframelights = workspace.MainframeLights:GetChildren()
		for i = 1, #mainframelights do
    	mainframelights[i].Light.PointLight.Color = Color3.new(1, 170/255, 0)
		mainframelights[i].Light.PointLight.Color = Color3.new(255, 170/255, 0)
		mainframelights[i].Light.BrickColor = BrickColor.new("Orange")
		end
	end
end
		
function alarmMajor()
	if currentTemp.Value >= 1000 then
		AlarmMajorS:Play()
		AlarmMinorS:Stop()
		--
		local emergencylightson = workspace.EmergencyLights:GetChildren()
		for i = 1, #emergencylightson do
    	emergencylightson[i].Toggle.Enabled = true
		--
		MainframeStatus.Text = "LavaBlast://Core_Status/Major"
		MainframeStatus.TextColor3 = Color3.new(255, 0, 0)
		--
		local fireone = workspace.Mainframe_Status_Fire_Parts:GetChildren()
		for i = 1, #fireone do
    	fireone[i].Fire.Enabled = true
		--
		local mainframelightstwo = workspace.MainframeLights:GetChildren()
		for i = 1, #mainframelightstwo do
    	mainframelightstwo[i].Light.PointLight.Color = Color3.new(1, 0, 0)
		mainframelightstwo[i].Light.PointLight.Color = Color3.new(1, 0, 0)
		mainframelightstwo[i].Light.BrickColor = BrickColor.new("Red")
		end
	end
end

		
function normalTemperature()
	if currentTemp.Value < 699 then
		AlarmMinorS:Stop()
		AlarmMajorS:Stop()
		MainframeStatus.Text = "LavaBlast://Core_Status/Stable"
		MainframeStatus.TextColor3 = Color3.new(255, 255, 255)
		local fireone = workspace.Mainframe_Status_Fire_Parts:GetChildren()
		for i = 1, #fireone do
    	fireone[i].Fire.Enabled = false
		--
		local mainframelightsthree = workspace.MainframeLights:GetChildren()
		for i = 1, #mainframelightsthree do
    	mainframelightsthree[i].Light.PointLight.Color = Color3.new(255, 255, 255)
		mainframelightsthree[i].Light.PointLight.Color = Color3.new(255, 255, 255)
		mainframelightsthree[i].Light.BrickColor = BrickColor.new("White")
		end
		end	
	end
end
	end
end
end

while true do
	wait(5)
	print "lol"
	normalTemperature()
	alarmMinor()
	alarmMajor()
end

And this is the error:

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

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

1 comment

1

Can you give us the full script? It looks like either normalTemperature, alarmMinor, or alarmMajor is not defined.

2 answers

✓ Accepted answer

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:

--snip

function alarmMinor()
	if currentTemp.Value >= 700 then
		--snip
		for i = 1, #firethree do
			--snip
			for i = 1, #mainframelights do
				--snip
			end
		end
	end

	function alarmMajor()
		if currentTemp.Value >= 1000 then
			--snip
			for i = 1, #emergencylightson do
				--snip
				for i = 1, #fireone do
					--snip
				end
			end
		end


		function normalTemperature()
			if currentTemp.Value < 699 then
				--snip
				for i = 1, #fireone do
					--snip
					for i = 1, #mainframelightsthree do
						---snip
					end
				end 
			end
		end
	end
end

while true do
	--snip
end

3 comments

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

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.

0

Yeah :)

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

For example:

testFunction()

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

2 comments

1

I am sure I defined it. I just edited my script to show it all.

0

Ahh. Thank you!

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