hello! i have made a game where theres a main menu and the player’s camera follows wherever their mouse cursor goes.
the problem is that it only seems to work when the spawn point is near “camera part” in workspace.
for example, if i move the spawn point somewhere far away from “camera part”, the player is no longer able to see what “camera part” is pointing at, and the script stops working completely.
here’s my script:
local RunService = game:GetService("RunService")
local players = game:GetService("Players")
local CameraPart = workspace:WaitForChild("CameraPart")
local CurrentCamera = workspace.CurrentCamera
local LocalPlayer = players.LocalPlayer
local Mouse = LocalPlayer:GetMouse()
local GUI = script.Parent
local PlayButton = GUI.PLAYBUTTON
local MOVE_SPEED = 150
local function UpdateCamera()
local Center = CameraPart.CFrame
local MoveVector = Vector3.new((Mouse.X - Center.X)/MOVE_SPEED, (Mouse.Y - Center.Y)/MOVE_SPEED, 0)
CurrentCamera.CFrame = CameraPart.CFrame * CFrame.Angles(math.rad(-(Mouse.Y - Center.Y)/MOVE_SPEED), math.rad(-(Mouse.X - Center.Y)/MOVE_SPEED), 0)
end
local Connection = RunService.RenderStepped:Connect(UpdateCamera)
PlayButton.Activated:Connect(function()
wait(2)
Connection:Disconnect()
end)
any help would be GREATLY appreciated! thanks!