Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is this TopDown Camera not working?

Hello,

I'm trying to make a TopDown Camera View for my game, but, now that I did the script and all, it's not letting me move(I can only jump).

Here's the code, it's inserted inside the Character


while true do
local cam=workspace.Camera
local plr=game.Players:GetPlayerFromCharacter(script.Parent)
cam.CameraType="Scriptable"
cam.CoordinateFrame=CFrame.new(plr.Character.Torso.CFrame.p+Vector3.new(0,35,0),plr.Character.Torso.Position)
cam.Focus=plr.Character.Torso.CFrame
wait()
end

You can test here if you want http://www.roblox.com/games/263405786/TopDown

3 comments

0

Insert it into a code block, just click the lua button when you edit the question and past the code inbetween the ~~~~~ lines

0

I'm gonna edit my answer, make it even better!

0

Great, thanks ill upvote

1 answer

✓ Accepted answer

The reason why your script wasn't working was because, you defined the camera's setting to Scriptable.

First Code

while true do
local cam=workspace.Camera
local plr=game.Players:GetPlayerFromCharacter(script.Parent)
cam.CoordinateFrame=CFrame.new(plr.Character.Torso.CFrame.p+Vector3.new(0,35,0),plr.Character.Torso.Position)
wait()
end

-- I removed the `focus` because, the focus isn't necessary. 

Edited Code

If you're suffering from frames not rendering as fast, use RenderStepped.

What is RenderStepped and what does it do?

RenderStepped is an event of RunService, this event fires Every frame in approximately 1/60 of a second.

game:GetService("RunService").RenderStepped:connect(function()
	local cam=workspace.Camera
	local plr=game.Players:GetPlayerFromCharacter(script.Parent)
	cam.CoordinateFrame=CFrame.new(plr.Character.Torso.CFrame.p+Vector3.new(0,35,0),plr.Cha	racter.Torso.Position)
end)

1 comment

0

Oh, but its glitchy when I zoom in and out. Any way to prevent the Plr from zooming?

This discussion is preserved as it was. New answers, comments, and votes are closed.