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 3 years ago
Edited 3 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:

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 3 years 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