So I am making a shooter-type game where the player's aim is wobbly and thus difficult to aim:
--services local UserInputService = game:GetService("UserInputService") local RunService = game:GetService("RunService") local Players = game:GetService("Players") --constants local LOCAL_PLAYER = Players.LocalPlayer local CAMERA = workspace.CurrentCamera local CHARACTER = LOCAL_PLAYER.Character or LOCAL_PLAYER.CharacterAdded:Wait() local HUMANOID = CHARACTER:WaitForChild("Humanoid") local HUMANOID_ROOT_PART = HUMANOID.RootPart local CHARACTERS = workspace:WaitForChild("Characters") --variables local x = 0 local y = 0 local vx = 0 local vy = 0 local modes = { "Default"; "Inertia" } local mode = 1 --functions --initiate CAMERA.FieldOfView = 80 CAMERA.CameraType = Enum.CameraType.Custom CAMERA.CameraSubject = CHARACTER UserInputService.MouseBehavior = Enum.MouseBehavior.Default RunService:BindToRenderStep("Camera", Enum.RenderPriority.Last.Value, function(dt) CAMERA.Focus = CFrame.new(HUMANOID_ROOT_PART.Position) if modes[mode] == "Inertia" then if vx < 0 then vx = vx + 0.1 elseif vx > 0 then vx = vx - 0.1 end if vy < 0 then vy = vy + 0.1 elseif vy > 0 then vy = vy - 0.1 end x = (x - vx * (1/260)) % (math.pi * 2) y = math.clamp(y - vy * (1/260), -1.4, 0.5) elseif modes[mode] == "Default" then end local center = HUMANOID_ROOT_PART.Position + Vector3.new(0, 4, 0) local cframe = CFrame.new(center) * CFrame.Angles(0, x, 0) * CFrame.Angles(y, 0, 0) * CFrame.new(0, 0, 20) local rotation = cframe - cframe.p local ray = Ray.new(center, (cframe.p - HUMANOID_ROOT_PART.Position)) local _, position = workspace:FindPartOnRayWithIgnoreList(ray, {}) CAMERA.CFrame = CFrame.new(position) * rotation end) UserInputService.InputChanged:connect(function(inputObject, processed) if not processed then if modes[mode] == "Inertia" then if vx < 10 and vx > -10 then vx = vx + inputObject.Delta.X * 0.05 end if vy < 10 and vy > -10 then vy = vy + inputObject.Delta.Y * 0.05 end elseif modes[mode] == "Default" then x = (x - inputObject.Delta.X * (1/260)) % (math.pi * 2) y = math.clamp(y - inputObject.Delta.Y * (1/260), -1.4, 0.5) end end end) LOCAL_PLAYER.CharacterAdded:Connect(function(character) CHARACTER = LOCAL_PLAYER.Character or LOCAL_PLAYER.CharacterAdded:Wait() HUMANOID = CHARACTER:WaitForChild("Humanoid") HUMANOID_ROOT_PART = HUMANOID.RootPart end)
This is the CameraScript. Although it works fine, my problem is that I don't know how to secure it from exploiters; for example, one could change the script so the camera isn't wobbly, giving him or her an advantage.
This is my theory.
Make a script that detects if your "CameraScript " has changed. If it has, it kicks the player off the game.