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

[REPOST] How can stop camera rotation on z axis? [closed]

Asked by 2 years ago

Hello, i am reposting this again because I haven't gone a response to my old question. This is a local script located in starterplayerscripts. I have character completely disabled, characterautoload set to false and i also have movement and camera set to scriptible. What i am trying to acomplish is a sandbox game where you can move around with the camera. But the problem is that whenever i try to move my camera on the x or y axis it creates a z axis. What i mean by this is the fact that the whole camera will move clockwise or counterclockwise based on where i move the mouse. I have tried to find answers on devfourm and google to no avail. A quick answer would be nice. Here is the code:

--Just a reminder there is no character at all so please set characterautoload to false and set devcomputer and devtouch to scriptible lastly set cameramode to lockfirstperson
local starterGui = game:GetService("StarterGui")
local uis = game:GetService("UserInputService")
local runService = game:GetService("RunService")
local plr = game:GetService("Players").LocalPlayer
local plrMouse = plr:GetMouse()
local camera = workspace.CurrentCamera
local rightMouseDown = false

starterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = CFrame.new(0, 50, 0)

plrMouse.Button2Down:Connect(function()
    rightMouseDown = true
end)

plrMouse.Button2Up:Connect(function()
    rightMouseDown = false
end)

runService.RenderStepped:Connect(function()
    if rightMouseDown == true then
        uis.MouseBehavior = Enum.MouseBehavior.LockCurrentPosition
        local mouseDelta = uis:GetMouseDelta()
        camera.CFrame = camera.CFrame * CFrame.Angles(math.rad(-mouseDelta.Y), math.rad(-mouseDelta.X), 0)
    else
        uis.MouseBehavior = Enum.MouseBehavior.Default
    end
end)

devfourm post ive read: How can I make a camera that moves freely? and How do I stop camera from rotating on Z axis? i also did read on the roblox developer hub about cframes and cameras too.

Locked by T3_MasterGamer and COUNTYL1MITS

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 2 years ago

I solved it on my own nvm

Ad