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

Strange Error With My Script Saying "attempt to compare function and number"?

So I Am Making A System That So When The Time Is Night Music Plays And Stop When Day But I Get The Error Of "attempt to compare function and number" The Error Is On Line 8

Note: This Is The Stop Script

Here Is The Script:

local crickets = script.Parent
local Tim = game.Lighting.ClockTime
local Time = Tim
tonumber(Time)
	 
game.Lighting.Changed:Connect(function(property)
	if property == "ClockTime" then
		if Time >= 6 and time <= 17 then
			crickets:Stop()
		end
	end
end)

1 answer

✓ Accepted answer

You seemed to have made a spelling mistake, you are comparing your variable 'Time' and the built-in Roblox Function 'time'

local crickets = script.Parent
local Tim = game.Lighting.ClockTime
local Time = Tim
tonumber(Time)

game.Lighting.Changed:Connect(function(property)
    if property == "ClockTime" then
        if Time >= 6 and Time <= 17 then --changed from 'time(roblox function)' to 'Time(your variable)'
            crickets:Stop()
        end
    end
end)

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