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?
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.
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.
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.
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.
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.
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)
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
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: