It's supposed to be a top-down view camera. It's a localscript in StarterPack. The problem is it works in Play Solo mode, but not Play mode (normal mode.) Here's the script:
local Camera = game.Workspace.CurrentCamera
local Torso = game.Players.LocalPlayer.Character.Torso
Camera.CameraType = "Scriptable"
Camera.CameraSubject = nil
repeat wait() until game.Players.LocalPlayer:FindFirstChild("PlayerGui")
local Player = game.Players.LocalPlayer
local size = Instance.new("ScreenGui", Player.PlayerGui)
size.Name = "Size"
local TMaxHeight = 200
local TMinHeight = 10
local TStep = 2.5
local THeight = 20
local Keys = {}
local Mouse = Player:GetMouse()
local mouse = Mouse
local dir = 0
-- USED KEYS SO FAR
-- E,Q,R,X
local Keys = {}
local Locked = false
local MouseTrack = false
function GetRotation(Unit)
--// Cosine in radian circle: y/x so angle alpha is cos-1(y/x) x=1
--// Problem here is the circle itself as they have 2 solutions.
local AbZ, AbX = math.abs(Unit.z), math.abs(Unit.x)
local Real = math.atan(AbX/AbZ)
--// ^ugly, super, super, ugly...
--// Now find the quadrant
local Plus = 0
--// Cases are Z and X
if Unit.z >= 0 and Unit.x >= 0 then
--Plus = 0
elseif Unit.z >= 0 and Unit.x < 0 then
Plus = (0.5 * math.pi)
Real = ((math.pi *1.5) - Real)
elseif Unit.z < 0 and Unit.x < 0 then
Plus = math.pi
elseif Unit.z < 0 and Unit.x >= 0 then
Plus = math.pi * 1.5
Real = ((math.pi * 1.5) - Real)
end
return Real + Plus
end
function Update()
if not Locked and not Button2Down then
if Keys["e"] then -- turn right
dir = dir + 1
end
if Keys["q"] then -- turn left
dir = dir - 1
end
if Keys["x"] then
dir = math.deg(GetRotation(Torso.CFrame.lookVector)) - 90
end
end
if not Button2Down then
if not Locked and not MouseTrack then
elseif MouseTrack then
local Size = Player.PlayerGui.Size.AbsoluteSize.X / 2
local Pos = mouse.X
local Diff = 0
if math.abs(Size - Pos) > Size / 20 then
local this = ((Size - Pos) / (Size))
local mul = (this < 0 and -1) or 1
Diff = math.sqrt(math.abs(this)) * 3 * mul
end
dir = dir + Diff
else
dir = math.deg(GetRotation(Torso.CFrame.lookVector)) - 90
end
end
local rot = math.rad(dir)
local x = -math.cos(rot)
local z = math.sin(rot)
local New = Vector3.new(x,0,z) / 1000
local this = (mouse.hit.p - Torso.Position ).unit
Camera.CoordinateFrame = CFrame.new(Vector3.new(Torso.Position.x, Torso.Position.y + THeight, Torso.Position.z) + New , Torso.Position)
Camera:SetRoll(math.rad(dir))
end
game:GetService("RunService").RenderStepped:connect(function()
Update()
end)
function Zoom(TStep)
THeight = ((THeight + TStep <= TMaxHeight and THeight + TStep >= TMinHeight) and THeight + TStep) or THeight
end
mouse.WheelBackward:connect(function()
Zoom(TStep)
end)
mouse.WheelForward:connect(function() Zoom(-TStep) end)
mouse.KeyDown:connect(function(key)
if key == "r" then
Locked = not Locked
if Locked then
MouseTrack = false
end
elseif key == "f" then
MouseTrack = not MouseTrack
if MouseTrack then
Locked = false
end
end
Keys[key] = true
end)
mouse.KeyUp:connect(function(key)
Keys[key] = false
end)
Thanks!
