So, I was trying to make a visible timer for a game… but I ran into a bit of a strange problem. On my last line of code, I get a strange error: Attempt to connect failed: Passed value is not a function
There are two weird things about this. One, the system functions a bit strangely before this, but that is a different issue, however, I get the error about 10 seconds in. Also, I have another line of code one line above the problem line which has no problems or errors. Does anyone know what’s happening?
The code:
wait(1)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local timer = game.Workspace.TimeCounter.Timer
local visibletimer = script.Parent.Parent.PlayerGui.TimeGUI.TG_Frame.TG_TimeLabel
local identifier = "wat"
local intermission = ReplicatedStorage:WaitForChild("Intermission")
local reset = ReplicatedStorage:WaitForChild("Reset")
local newserver = ReplicatedStorage:WaitForChild("NewServer")
local enoughplayers = false
timer.Changed:Connect(function()
visibletimer.Text = identifier .. timer.Value
end)
intermission.OnClientEvent:Connect(function()
enoughplayers = true
identifier = "Intermission: "
end)
local function notenoughplayers()
repeat
visibletimer.Text = "Waiting for players."
wait (0.75)
visibletimer.Text = "Waiting for players.."
wait (0.75)
visibletimer.Text = "Waiting for players..."
wait (0.75)
until enoughplayers == true
end
reset.OnClientEvent:Connect(notenoughplayers())
newserver.OnClientEvent:Connect(notenoughplayers())
(BTW this is in a LocalScript located in a GUI inside of StarterGUI)