local player = game.Players.LocalPlayer
local character = player.Character
while true do
if character:FindFirstChild("HumanoidRootPart") then
--code here
end
end
I just tried your second option and now there is an error that says [Players.Programmed_Model.PlayerGui.SurfaceGui.LocalScript:15: attempt to call global ‘Vector3’ (a table value)
CODE:
local CircularMap = game.ReplicatedStorage.CircularMap:Clone()
CircularMap.Parent = workspace
local FakeCam = Instance.new("Camera")
FakeCam.Parent = script.Parent
FakeCam.CameraType = Enum.CameraType.Scriptable
script.Parent.Adornee = CircularMap.PrimaryPart
script.Parent.ViewportFrame.CurrentCamera = FakeCam
workspace.Map:Clone().Parent = script.Parent.ViewportFrame
while true do
CircularMap:SetPrimaryPartCFrame(workspace.CurrentCamera.CFrame*CFrame.Angles(math.rad(90),0,0)*CFrame.new(-10,-10,-5))
FakeCam.CFrame = CFrame.new(game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Position + Vector3(0,50,0),game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Position)
game:GetService("RunService").RenderStepped:Wait()
wait()
end
Use the following strings to define parts of the character:
local player = game:GetService('Players').LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local HumanoidRootPart = character:WaitForChild('HumanoidRootPart')
Additionally, optimize your while loop by binding the enclosed function inside of a RenderStepped loop:
Unless you’re updating the camera, stay away from RenderStepped. You can block the execution of render ticks since it runs before a frame and expensive code there can slow down performance on the client’s end. Ideally you should use Stepped which runs before physics are simulated.