Hello,
I am creating a maze in one of my games and I would like it if players weren't able to zoom out whilst doing it to cheat their way to the finish.
I took some code from an old post on here about limiting the camera zoom distance; https://scriptinghelpers.org/questions/44213/
I'm not sure if the code is outdated or if something else is wrong with my script, but any help would be hugely appreciated :)
local PlayerDebounce = {} script.Parent.Touched:connect(function(hit) wait() local humanoid = hit.Parent:FindFirstChildOfClass("Humanoid") if humanoid and not PlayerDebounce[hit.Parent] then PlayerDebounce[hit.Parent] = true wait(0.2) game:GetService("Players").LocalPlayer.CameraMaxZoomDistance = 1 game:GetService("Players").LocalPlayer.CameraMinZoomDistance = 1 wait(0.5) PlayerDebounce[hit.Parent] = nil end end)
Well, I'm not sure what you want to achieve exactly
But if you want to change the player's max zoom distance when they touch a brick, you can use this
----- Customize ----- local MaxZoom = 1 -- Set this number to whatever max zoom distance you want ----- End ----- local brick = script.Parent function touched(hit) if hit.Parent:FindFirstChild("Humanoid") then local char = hit.Parent local plr = game.Players:GetPlayerFromCharacter(char) plr.CameraMaxZoomDistance = MaxZoom end end brick.Touched:Connect(touched)