How would I make a dynamic top down view camera?

That’s really unusual, there may be a script in that gun that conflicts with the camera, could you try to use this code in a new fresh place?

I see there was something called “weapon system” in Output, I bet that’s causing the problem.

If its an open sourced module, can you post the link to it? So i can check out whats causing the problem.


nope it does not even work on a fresh new place it just top down view again…
but after putting pistol model in, the camera would start changing when moving with your mouse but then the top down view is not working.

The system it self is in replicate storage, dissable it if anything.

1 Like

Code itself works fine its must be coliding with diffrent scripts in your game.

maybe i needed to do something more than putting the script in ‘‘StarterPlayerScripts’’

Nope, thats all you need, i can see that “Weapon System” wasnt desined for top view in mind.

oh wait you need to put it in “StarterCharacterScripts”

ohh now it works but still something is wrong
the camera falls on
ground

Yea I updated the code to be actually “Top View” just copy and paste.

Thank you so much now it works just fine :slight_smile:

1 Like

hey uhh i know its solved and it’s old but… i put the script in both starter character scripts and starter player scripts, heres the error:

  16:12:57.746  ScreenGui is not a valid member of StarterGui "StarterGui"  -  Client - Top-Down:9
  16:12:57.747  Stack Begin  -  Studio
  16:12:57.747  Script 'Workspace.foxnoobkite.Top-Down', Line 9  -  Studio - Top-Down:9
  16:12:57.747  Stack End

You need a ScreenGui for it to work, without it cant calculate proper mouse movement.

this thing

thing

Create a ScreenGui in StarterGui and that’s it.

1 Like

hmmmm im trying to make it a tiny bit vertical like the game vertix.io, I mooded the position value but I can’t get it to the middle

 -- Made by ThanksRoBama.
-- Explained and polished by Czlopek

local Player = game:GetService("Players").LocalPlayer	
local player = game.Players.LocalPlayer
local mouse = Player:GetMouse()
local camera = workspace.CurrentCamera
local runService = game:GetService("RunService")
local screenGui = game.StarterGui.ScreenGui

-- here is your template for Vector3 axis (x y z)

local Distance = Vector3.new(0,25,0) -- Distance from player
local Direction = Vector3.new(45,-90,0) -- Direction from which camera will be looking at player
local CameraSensitivity = 20 -- change it if you want that camera to lean further (give it a bigger number) 
-- or if want an effect to be more subtle decrease the number. (if you set it as a negative, camera will lean in the opposite direction)

function getMouseScreenPositionCentered() 
	return Vector2.new(
		mouse.X - screenGui.AbsoluteSize.X/2,
		mouse.Y - screenGui.AbsoluteSize.Y/2)
end

function pixelToFraction(pixelV2)
	--Turns a coordinate in pixels into a coordinate in some fraction of the size of the screen
	return pixelV2 / screenGui.AbsoluteSize
end

function onRenderStep() 	
	if player.Character then
		local rootPart = player.Character.HumanoidRootPart
		local playerposition = player.Character.HumanoidRootPart.Position + Vector3.new(0,0,3) -- sometimes camera will be offset to your character, 
		-- thats why you need to add few studs to it so it would stay in middle of the screen.
		local cameraoffset = Distance + playerposition

		local mouseScreenPos = pixelToFraction( getMouseScreenPositionCentered() )
		local Axis = Vector3.new(-mouseScreenPos.Y,0,mouseScreenPos.X)

		local cameraPos = cameraoffset + Axis * CameraSensitivity 


		-- depending on what direction you set the camera to be facing remember that you will need to change it accurately to direction of the camera. 
		-- top down view will have Direction = Vector3.new(0,-1,0) and Axis = Vector3.new(-mouseScreenPos.Y,0,mouseScreenPos.X)
		-- side ways Direction = Vector3.new(0,0,-1) Axis = Vector3.new(mouseScreenPos.X,-mouseScreenPos.Y,0)

		camera.CFrame = CFrame.new(cameraPos, cameraPos + Direction)
	end
end

runService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onRenderStep)

when i but the y value to -1, it looked like this:

Change “Vector3.new(0,0,3)” at the end of line 32 to “Vector3.new(-12,0,0)”
Worked for me.

hmmm i want it to be in a -45 degree angle, when i changed the -12 to 45, it’s center isn’t my player for some reason

You need to change the “Direction” vector to “Vector3.new(1,-1,0)” it will add on those values resulting in a 45-degree angle, and then change the value at line 32 to “Vector3.new(-24,0,0)” so it is centered on the player.

1 Like