Help with lua type annotation error

The script works great, but C:Disconnect has this annoying error that bothers me and I dont know how to fix it. I tried changing the type, making the variable global, directly connect the variable to the function ect. But theres always some sort of type error no matter what.

--!strict
local UIModule = {}
local RunService: RunService = game:GetService("RunService")

function UIModule:UpdateTimer(Endtime: number)
	local Players = game:GetService("Players")
	local Player = Players.LocalPlayer
	if not Player then return end
	local TimerUI: TextLabel = Player.PlayerGui.RoundUI.Timer
	
	local C: RBXScriptConnection
	C = RunService.RenderStepped:Connect(function()
		local CurrentTime: number = os.clock()
		local TimeLeft: number = Endtime - CurrentTime
		
		if TimeLeft <= 0 then
			TimerUI.Text = "0.00"
			C:Disconnect() 
		else
			TimerUI.Text = string.format("%.2f", TimeLeft)
		end
	end)
end

return UIModule

image

I can’t think of any solutions here. Are you using the new type solver? It’s riddled with bugs; you might as well roll back for now. On another note, Players.LocalPlayer is guaranteed to exist at all times on the client. If that guard is intended to prevent Scripts from using client-dependant functions, use RunService:IsServer as the basis of your guard

Yeah im using the beta feature lua type checker, I probably should’ve said that the Module script is located in starter gui. The reason that I have a guard to check for the player is because it stops another type error from popping up.

Yeah, as I said, riddled with bugs. Just roll back until it’s out of beta

I turned off the beta setting, and used the normal lua type checker, now the errors are gone. It isnt as strict as the beta type checker, but its better than having errors.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.