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

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

Asked by 4 years ago
Edited 4 years ago

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:

01local crickets = script.Parent
02local Tim = game.Lighting.ClockTime
03local Time = Tim
04tonumber(Time)
05 
06game.Lighting.Changed:Connect(function(property)
07    if property == "ClockTime" then
08        if Time >= 6 and time <= 17 then
09            crickets:Stop()
10        end
11    end
12end)

1 answer

Log in to vote
1
Answered by 4 years ago

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

01local crickets = script.Parent
02local Tim = game.Lighting.ClockTime
03local Time = Tim
04tonumber(Time)
05 
06game.Lighting.Changed:Connect(function(property)
07    if property == "ClockTime" then
08        if Time >= 6 and Time <= 17 then --changed from 'time(roblox function)' to 'Time(your variable)'
09            crickets:Stop()
10        end
11    end
12end)
Ad

Answer this question