I am using a freecam script i found on the devforum and need help modifying it a bit. Every time I enable the freecam script, it resets the angle of the camera/player to (0,0,0) (It is using CFrame.Angles). I am wondering if there is any way to prevent it from reseting the players angle (the direction they are looking towards) when activating the script.
#Freecam Script Angles
40 messages · Page 1 of 1 (latest)
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
local KEY_DIRECTIONS = table.freeze({
[Enum.KeyCode.A] = Vector3.new(-1, 0, 0),
[Enum.KeyCode.D] = Vector3.new(1, 0, 0),
[Enum.KeyCode.S] = Vector3.new(0, 0, 1),
[Enum.KeyCode.W] = Vector3.new(0, 0, -1),
})
local TURN_SPEED = 1/90 -- in radians/pixel
local SHIFT_SPEED = 8 -- in studs/second
local MOVE_SPEED = 40 -- in studs/second
local shiftPressed = false
local activeDirections = {}
local x = 0
local y = 0
local angle = CFrame.Angles(0, x, 0) * CFrame.Angles(y, 0, 0)
local position = camera.CFrame.Position
UserInputService.InputBegan:Connect(function(input)
if KEY_DIRECTIONS[input.KeyCode] then
activeDirections[input.KeyCode] = KEY_DIRECTIONS[input.KeyCode]
elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCurrentPosition
elseif input.KeyCode == Enum.KeyCode.LeftShift then
shiftPressed = true
end
end)
UserInputService.InputEnded:Connect(function(input)
if KEY_DIRECTIONS[input.KeyCode] then
activeDirections[input.KeyCode] = nil
elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
UserInputService.MouseBehavior = Enum.MouseBehavior.Default
elseif input.KeyCode == Enum.KeyCode.LeftShift then
shiftPressed = false
end
end)
UserInputService.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
x = (x - input.Delta.X * TURN_SPEED)%(2*math.pi)
y = math.clamp(y - input.Delta.Y * TURN_SPEED, math.rad(-89), math.rad(89))
angle = CFrame.Angles(0, x, 0) * CFrame.Angles(y, 0, 0)
elseif input.UserInputType == Enum.UserInputType.MouseWheel then
position += angle * Vector3.new(0, 0, -5*input.Position.Z)
end
end)
RunService.RenderStepped:Connect(function(dt)
local move = Vector3.zero
for _, v in pairs(activeDirections) do
move += v
end
local speed = if shiftPressed then SHIFT_SPEED else MOVE_SPEED
position += angle * (move * speed * dt)
camera.CFrame = angle + position
end)
script is from here https://devforum.roblox.com/t/making-an-instant-stop-with-a-bodyforce/256551/6
Developer Forum | Roblox
I was bored and I made CameraScripts before, so I made this fully functional snippet of code that behaves like studio’s default camera system for you: local RunService = game:GetService("RunService") local UserInputService = game:GetService("UserInputService") local TweenService = game:GetService("TweenService") local camera = workspace.Curren...
What im basically trying to say is how do i grab the players camera CFrame.Angles and set my workspace camera to the same angle
uh huh
** You are now Level 6! **
❤️ fr
uh
cant u just copy it
im on phone rn
it goes in startergui btw
i have a script that enables and disables the script
naw
just enable the script 💀
localscript in startergui
make sure u copy both
since its too long
thanks btw ive been trying to fix dis shit for a few hrs
bruh
wtf did u do 💀
damn
💀
ima go kms
👍
bro
i swear
i did that
bro
i put it as x,yz
i never bothered to change that after i didnt work
fuck man 😭
alr ty bro
ill check if it works in a sec
im tryna fix cb:ro rn