Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make CameraScript secure from exploits?

Asked by 6 years ago

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.

0
It wouldn't matter it will only do it for them not for others User#19524 175 — 6y
0
I'm not worried about that, but the fact that the exploiter can edit his or her own camera script is the problem. User#17080 0 — 6y
0
Then check if it changes. If it does, kick them User#19524 175 — 6y
0
But the thing is, the exploiter might edit the script so it doesn't check. User#17080 0 — 6y
1
Exploiters can't edit scripts. They can grab and use the environment or mess with funcitons, but they can't change code in scripts. poke7667 142 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

This is my theory.

Make a script that detects if your "CameraScript " has changed. If it has, it kicks the player off the game.

0
That's not your theory... i can see the same thing being said by Incapaz and i can see Incapaz said it first GamingOverlord756 48 — 6y
Ad

Answer this question