My topdown camera is messing with my menu and I dont know why here are the scripts,
–topdown
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:WaitForChild(“StarterGui”).ScreenGui– here is your template for Vector3 axis (x y z)
local Distance = Vector3.new(0,40,0) – Distance from player
local Direction = Vector3.new(0,-1,0) – Direction from which camera will be looking at player
local CameraSensitivity = 10 – 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)
endfunction pixelToFraction(pixelV2)
–Turns a coordinate in pixels into a coordinate in some fraction of the size of the screen
return pixelV2 / screenGui.AbsoluteSize
endfunction onRenderStep()
if player.Character thenlocal 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
endrunService:BindToRenderStep(“Camera”, Enum.RenderPriority.Camera.Value, onRenderStep)
–menu
local cc = workspace.CurrentCamera
local pc = workspace.PlayCam
local tc = workspace.TutorialCam
local player = game.Players.LocalPlayer
local pb = script.Parent.Play
local tb = script.Parent.Tutorial
wait(.001)
cc.CameraType = Enum.CameraType.Scriptable
cc.CFrame = pc.CFrame
local function playEntered()
cc.CFrame = pc.CFrame
end
local function tutorialEntered()
cc.CFrame = tc.CFrame
end
tb.MouseEnter:Connect(tutorialEntered)
pb.MouseEnter:Connect(playEntered)