Using math.huge as a number completely breaks my script

I am currently trying to use math.huge for a project so a gui will display infinitely. Whats the problem? My module uses task.wait(self.VisibleTime - 1 + self.TweenLength1) to wait until the gui needs to be removed, but when I turn self.VisibleTime into math.huge, nothing displays at all. Someone please help as I have been confused with this issue for a long time.

Thanks in advance, and of course, best regards,
@maddjames28

1 Like

You should use an escape condition or a function call to make the UI go away instead of using an arbitrary wait time; math.huge() is intractable, so the task schedular can’t “wait for a huge time.” Mind showing the script? The phrase “gui will display infinitely” is confusing since you could just not disable the UI at all if it’s supposed to be on-screen forever.

1 Like

Function in question (everything that’s in self was already set.)

function HS:activateHint(yieldThread : boolean)
	yieldThread = yieldThread or false
	local function activateHint()
		local label = self._
		label.Visible = true
		if self.VisibleTime <= 1 then
			error("Max visible time cannot be 1 or under.")
		end
		HS.HintAdded:Fire(label)
		TweenService:Create(label, TweenInfo.new(self.TweenLength1, self.EasingStyle1, self.EasingDirection1), {TextTransparency = self.LabelTransparency}):Play()
		TweenService:Create(label, TweenInfo.new(self.TweenLength1, self.EasingStyle1, self.EasingDirection1), {BackgroundTransparency = self.HintTransparency}):Play()
		TweenService:Create(label:WaitForChild("BorderUIStroke"), TweenInfo.new(self.TweenLength1, self.EasingStyle1, self.EasingDirection1), {Transparency = self.HintTransparency}):Play()
		TweenService:Create(label:WaitForChild("TextUIStroke"), TweenInfo.new(self.TweenLength1, self.EasingStyle1, self.EasingDirection1), {Transparency = self.LabelTransparency}):Play()
		task.wait(self.VisibleTime - 1 + self.TweenLength1)
		HS.HintRemoving:Fire(label)
		TweenService:Create(label, TweenInfo.new(self.TweenLength2, self.EasingStyle2, self.EasingDirection2), {Transparency = 1}):Play()
		TweenService:Create(label:WaitForChild("BorderUIStroke"), TweenInfo.new(self.TweenLength2, self.EasingStyle2, self.EasingDirection2), {Transparency = 1}):Play()
		TweenService:Create(label:WaitForChild("TextUIStroke"), TweenInfo.new(self.TweenLength2, self.EasingStyle2, self.EasingDirection2), {Transparency = 1}):Play()
		if self.DestroyOnFinished == true then
			task.wait(self.TweenLength2)
			label:Destroy()
		end
	end
	if yieldThread then
		activateHint()
	else
		task.spawn(activateHint)
	end
end

Please tell me if I could make this code better, it just seems so bloaty and unneeded in certain areas.

1 Like

math.huge represents any value greater than the largest Lua integer. It isn’t intended to be used in arithmetic/comparison operations.

print(math.huge == (math.huge - 1)) --true, (both evaluate to 'inf')
1 Like

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