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

Having trouble with custom camera script, conflicting with player movements, what's wrong?

Asked by 9 years ago

What I wanted to do was: Make the player's camera at all times be a few studs behind the player and always rotated toward the players.

I managed to do this, but if I walk backwards my character just goes in circles. Also, If press w and walk forward only, The camera moves with my character, so the character is slowly going in the left or right direction as well as up.

To be honest, I haven't changed much of the code except little parts, because I don't know where to start to fix the 2 issues I have.

If this will help, I'm trying to make the camera be like a third person camera, but can't be controllable. So its looking at the player in third person. Kinda like a Third Person Shooter, except it's not going to be a shooter game.

This is my code, and its not even very great. If someone can make it neater and better while fixing my backwards problem, I wouldn't mind :). But you dont have to:

char = game.Players.LocalPlayer.Character

camera = game.Workspace.CurrentCamera
camera.CameraType = "Scriptable"

game:GetService("RunService").RenderStepped:connect(function()
    camera.CoordinateFrame = char.Head.CFrame * CFrame.new(0,3,10) * CFrame.Angles(math.rad(-20),0,0)
end)

This is in a Localscript inside StarterGui. Can someone help me?

0
Can someone please help? Ive been trying to fix it for so long. Drakonking10 5 — 9y

Answer this question