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

Why is this TopDown Camera not working?

Asked by
KoreanBBQ 301 Moderation Voter
8 years ago

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

0
Insert it into a code block, just click the lua button when you edit the question and past the code inbetween the ~~~~~ lines dragonkeeper467 453 — 8y
0
I'm gonna edit my answer, make it even better! woodengop 1134 — 8y
0
Great, thanks ill upvote KoreanBBQ 301 — 8y

1 answer

Log in to vote
1
Answered by
woodengop 1134 Moderation Voter
8 years ago

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)
0
Oh, but its glitchy when I zoom in and out. Any way to prevent the Plr from zooming? KoreanBBQ 301 — 8y
Ad

Answer this question