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

Scriptable First Person??

Asked by 9 years ago

****First Person Script, there are no problems with my script, but how could I make this more efficient by not having to go through thousands of lines (mouse.X) when you find "Mouse0 = 0" and stuff like that how could I make that a bit better? I want this script to be the best of its ability. Is there a way to make it something like Mouse0 = math.rad(0)math.rad(20) -- math.rad(start number) - math.rad(end number) I know i could do this the script only pays attention to the first number (start number)

player = game.Players.LocalPlayer -- Defines our player

mouse = player:GetMouse() -- Gets our mouse

cam = game.Workspace.CurrentCamera -- Gets the camera

local angle = 0 -- angle

Mouse0 = 0 -- mouse0
Mouse1 = 646 --mouse1
Mouse2 = 1292 --mouse2

maxleftangle = 0.45 -- the furthest the camera can move to the left
maxrightangle = -0.45 -- the furthest the camera can move to the right

target = game.Workspace.Sounds -- Note this is just the thing we are going to be putting our camera to look at

wait(2) -- Wait 2 seconds

cam.CameraSubject = target -- Changes the camera subject to the target
cam.CameraType = "Scriptable" -- makes the camera type scriptable
cam.CoordinateFrame = CFrame.new(target.Position) -- changes the camera position to the targets position

mouse.Move:connect(function() -- Detects when the mouse moves
    if mouse.X == Mouse0 and angle ~= maxleftangle then -- checks if the mouse is equal to Mouse0 and not at maxangle
        cam.CameraType = "Scriptable" -- Keeps the camera still scriptable just incase the first time it did not work
        cam.CoordinateFrame = CFrame.new(target.Position) *CFrame.Angles(0,angle,0) -- Changes the angle
        angle = angle +.05 --Adds +.05 to the angle
        print(angle) -- This will print the angle
    else -- else
        if mouse.X == Mouse1 then -- if mouse == 1 then
            print("Mouse is in the middle of the screen") -- print mouse is in the middle of the screen
        else -- else
            if mouse.X == Mouse2 and angle ~= maxrightangle then -- Detects if its equal to mouse2 and not at maxangle
            cam.CameraType = "Scriptable" --makes sure its still scriptable
                cam.CoordinateFrame = CFrame.new(target.Position) *CFrame.Angles(0,angle,0) -- Changes angle
        angle = angle -.05 -- subtracts .05 from the angle
        print(angle) -- prints
            else -- makes it so no errors will happen
            end -- Ends the script
        end
    end
end)

1 answer

Log in to vote
0
Answered by 9 years ago

There is a WAY easier way to do this. Make a LocalScript, and put it in the StarterPack (or StarterGui). Then put this line in the script:

game.Players.LocalPlayer.CameraMaxZoomDistance = 0

And you're done! If you want to go out of FP mode, you can change the number. The number dictates how far you can zoom out. You need to have it at least 2 to be zoom out enough to move the mouse without moving the camera.

Ad

Answer this question