PlayerModule.CameraModule.TransparencyController:168: invalid argument #3 to 'clamp'

I keep a log of client-side errors, and have one that keeps happening a lot. I’m curious what this error could be about:

Players.playernamehere.PlayerScripts.PlayerModule.CameraModule.TransparencyController:168: invalid argument #3 to 'clamp' (max must be greater than or equal to min)|cfbd26ca-5e20-4c1d-94cd-7dea7e523588

It seems to be code related to making things that are near the camera transparent or something, anyway it’s built-in code that I didn’t write.

Maybe this is from players who are trying to use some exploit?

1 Like

As the error clearly states, the math.clamp function is throwing because the third argument which is supposedly the maximum value to fallback to if the first argument is greater than it is less than the second argument which is the minimum value to fallback to.

you should pass min and max arguments in order to math.clamp function so

math.clamp(value,minimum value,maximum value)

minimum can’t be greater than maximum so you have to invert them. For example

--wrong 
math.clamp(value,50,30)
--correct
math.clamp(value,50,80)
3 Likes

Thank you. I’m aware of what clamp does, but this error is from Roblox code which is included in every game by default, so if mine has an error then I guess every other game has as well. But I would guess this is because some exploit is trying to mess with the camera.

1 Like

I have the exact same issue in my game right now. We are interpolating the camera position ( to give camera back to player) and it throw this error about clamping… which I have no control over. Curious if anyone else has seen this and how they fixed it.

1 Like

My code:

local player = game.Players.LocalPlayer
local controls = 
require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule):GetControls()


script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Visible = false
	local camera = game.Workspace.CurrentCamera
	local cameraPanTime = 2

	-- Enable Player movement
	controls:Enable();				

	-- Move the camera	
	camera:Interpolate(
		player.Character.PrimaryPart.CFrame,
		player.Character.PrimaryPart.CFrame,
		cameraPanTime
	)
	wait(cameraPanTime)


	camera.CameraType = Enum.CameraType.Custom

	
end)

Ive been having the same problem in my game. There are no scripts modifying the camera and this error randomly appears occasionally though it hasn’t caused any problems yet.

1 Like

I also had this even without modifying the camera, and while I’m not aware of any issues (apart from spamming my error logs), without understanding the cause I worry if they could be causing problems to the affected players.

1 Like

I took a look at the code for that specific module and I might have identified the issue. The script uses tick() which is a deprecated function, so there’s a chance that the line

local maxDelta = MAX_TWEEN_RATE * (now - self.lastUpdate)

(where MAX_TWEEN_RATE = 2.8, now = tick(), & lastUpdate = previous tick())

is evaluating to zero because something’s happening locally to make tick() either seize up or repeat values. It could be anything from an fps unlocker to someone injecting code into their client. Considering tick() only rounds to the nearest thousandth, it’s likely the former. This is a situation where that module needs to use os.clock() instead of tick() in order to get an accurate result

1 Like

From what I know, tick() still works, since I had been using it alot up until I found out it was deprecated a few days ago.

When I looked at the script, I assumed the issue was due to float precision because the only way this could happen is if lastUpdate was higher that tick(), which, without a loss of precision, shouldn’t be possible as lastUpdate is set to tick() on creation and after TransparencyController:Update is called.

Yea tick still works, but it’s been removed from all official documentation IIRC so I’m assuming it’s deprecated in favor of the os time functions.

That’s basically what I was trying to say but my thought here is that FPS unlockers cause either tick or that local module to go haywire. I’m basing my thought off of this post here:

I just want to report that this error is still happening to this day and that it is spamming my error logs.

3 Likes

same thing has been happening to me for the past half year

1 Like

hi did you fix your problem and how did you fix it?

You must set your CameraType to Scriptable. You cannot manipulate the camera unless you set it to Enum.CameraType.Scriptable.

1 Like