I have a arrow in a viewport frame. How do I rotate the arrow (or the viewport camera around the arrow) so the arrow is pointing at a part relative to where the players current camera is.
For example this arrow would point at a part if the part was too the left of the players camera view.
Put this script inside the arrow in the viewport frame.
local PartToPointTo = ThePartYouWantToPointTo
while wait() do
Script.Parent.Position = workspace.CurrentCamera.CFrame.LookVector * 2
Script.Parent.CFrame = CFrame.new(Script.Parent.Position, PartToPointTo.Position)
end
So I tried editing my most recent post’s script. I’m sorry for not getting it right the first time. DISCLAIMER: I do not have access to roblox studio currently and therefore can’t test these scripts. But hopefully these help you. Also make sure that the viewport’s current camera property is set to the workspace’s current camera.
Do you have a video of the code I put in? Like a video of testing it. This can help me look at what’s happening and makes it so much easier for me to help. Is this viewport frame a surface gui or is it a 2D gui?
local playerGui = player:WaitForChild("PlayerGui"):WaitForChild("ScreenGui")
local c = Instance.new("Camera")
c.Parent = playerGui.Job.ViewportFrame
playerGui.Job.ViewportFrame.CurrentCamera = c
while true do
playerGui.Job.ViewportFrame.Pointer.Position = CustomCamera.camera.CFrame.LookVector * 2
playerGui.Job.ViewportFrame.Pointer.CFrame = CFrame.new( playerGui.Job.ViewportFrame.Pointer.Position, workspace.Help.Position)
game:GetService("RunService").Heartbeat:wait()
end
Ok, you should try not using a new camera inside the viewport frame and just set the viewport frame’s current camera to the player’s camera. How does your custom camera work?
I figure it out in case anyone has the same problem
Basically I too the CFrame of the pointers position while looking at the part position - the players position.
I then multiplied that CFrame with the CFrame of the cameras angle.
Finally i set the pointers CFrame to this.