Can't move when camera is above

I tried making camera look from above, problem is now the player can’t move.
I know where the bug is, i just Don’t know how to fix it.

Video of the bug :

I didn’t put most variables due to readibility concerns. Also there are no other scripts


local distance = 20 --// Change this to how many studs you want it to be above the player's hrp

local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable

camera.FieldOfView = 110

runService.RenderStepped:Connect(function()
	camera.CFrame = CFrame.new(hrp.Position + Vector3.new(0, distance, 0)) * CFrame.Angles(math.rad(-90), 0, 0) -- Bug
	-- When I Don't put * CFrame.Angles(math.rad(-90), 0, 0) i can move but the camera is not looking at the player
end)

I think it’s because its in worldspace?

Try setting it from object space instead:

e.g.

camera.CFrame = camera.CFrame * CFrame.new(hrp.Position + Vector3.new(0, distance, 0)) * CFrame.Angles(math.rad(-90), 0, 0) -- Bug
1 Like

I think its because when you move in roblox, your move direction is relative to the camera

Smell like seizures

Because you need to offset it now by the original CFrame that was worldspace

like for example:

part.CFrame = part.CFrame * CFrame.new(0,2,0) -- 2 studs above original position

Instead of:

part.CFrame = CFrame.new(10,0,0) -- It will be in worldspace

Or in your case:

part.CFrame = part.CFrame * CFrame.new(10,0,0) -- It will move 10 studs on the x axis from the original pos

@Amritss don’t work, watch the clip above your reply

30char

Nooo bro you’re not understanding, did you watch a tutorial?

no, I just tried what you did about offset and it gave me stage 2 epilepsy on my screen

But I didn’t mean LITERALLY omg

It’s kinda hard to explain but i’ll try give me a sec.

Did you copy paste the code fully because it wasn’t mean to work but it was meant to give the idea of object space.

i did this

camera.CFrame = camera.CFrame * CFrame.new(0, distance, 0) * CFrame.Angles(math.rad(-90), 0, 0) 

Oh, then yeah Idk I thought it could’ve been cuz of worldspace.

I don’t get it. In the video, you moved forward just fine? I also tested the code and it doesn’t break for me.

Are you trying to use the arrow keys to move? If so, the left and right arrow does not move the character, but instead rotates the default camera behavior, but the up and down arrow does.

idk i’m using wasd as usual.

30char

Bro really thought I pasted

part.CFrame = part.CFrame * CFrame.new(10,0,0)

in my script :skull:

i restarted studio and still get epilepsy screen

Yeah, cannot replicate it on my end. Can you show the entire code? This is the only script right, nothing else is interfering with the movement or sinking the ContextActionService?

Does it also not work on a fresh baseplate and on a live server? If it works on a live server, then your studio might just be bugged somehow.

P.S. your original script works fine btw

I feel utterly and completely bamboozled

Here is the full script

local Players = game:GetService("Players")
local runService = game:GetService("RunService")

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local hrp = character:WaitForChild("HumanoidRootPart")

local distance = 20 --// Change this to how many studs you want it to be above the player's hrp

local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable

camera.FieldOfView = 110

runService.RenderStepped:Connect(function()
	camera.CFrame = camera.CFrame * CFrame.new(0, distance, 0) * CFrame.Angles(math.rad(-90), 0, 0) -- Bug
end)

Now i feel terribly bamboozled : the original script works on an empty baseplate

And you’ve restarted studio on your original game? Can you take a screenshot on what your explorer looks like with the entire contents?