Ad
Log in to vote
0

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

Asked by 2 days ago
Edited 2 days 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:

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

Log in to vote
1
Answered by 2 days ago

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)
Ad

Answer this question