How could I use a GUI on an object as a targeter?

What I mean is like how a retical shows where an object will hit but I want the player to be able to look away and the object would still hit the the position infront of the GUI.

you mean the stuff you see on call of duty?

Explorer:

Screenshot 2022-07-22 183235

LocalScript:

local RunService = game:GetService("RunService")
local Players = game:GetService("Players")

local Character = nil
local Tool = script.Parent
local Handle = Tool:WaitForChild("Handle")

local VisualRedDot = nil

RunService.RenderStepped:Connect(function()
	if VisualRedDot then
		local BlacklistParams = {VisualRedDot}

		if Character then
			for i, BaseParts in pairs(Character:GetDescendants()) do
				if BaseParts:IsA("BasePart") then
					table.insert(BlacklistParams, BaseParts)
				end
			end
		end

		local RaycastParam = RaycastParams.new()
		RaycastParam.FilterType = Enum.RaycastFilterType.Blacklist
		RaycastParam.FilterDescendantsInstances = BlacklistParams

		local Raycast = workspace:Raycast(Handle.Position, Handle.CFrame.LookVector * 500, RaycastParam)

		if Raycast then
			VisualRedDot.Position = Raycast.Position
		end
	end
end)

Tool.Equipped:Connect(function()
	local RedDot = Instance.new("Part")
	RedDot.TopSurface = Enum.SurfaceType.Smooth
	RedDot.BottomSurface = Enum.SurfaceType.Smooth
	RedDot.Size = Vector3.new(0.1, 0.1, 0.1)
	RedDot.Color = Color3.new(1)
	RedDot.Material = Enum.Material.Neon
	RedDot.Parent = game.Workspace
	RedDot.Anchored = true

	Character = Tool.Parent

	VisualRedDot = RedDot
end)

Tool.Unequipped:Connect(function()
	if VisualRedDot then
		VisualRedDot:Destroy()

		VisualRedDot = nil
	end
end)

Not exacly but close, it is basically a GUI on a screen that will show you where an object will hit and the object will hit that location no matter where you look at(like you turn 180 degree and the object will hit on the same location as you are looking at it) and no matter where is your mouse the object will consistantly hit that location.


To further explain the situation, I am looking into the sky but the object must hit the target(imagine there is a GUI at the bottem right of the picture).

place a SurfaceGui or an BillboardGui

on the target

The hit location will always be different but I am using the picture as an example.

For example, an armed vehicle is moving and you are using the turret mounted on it to fire and you are using the iron sight on it to know where the bullet will hit. Summery is the position where the bullet will hit is always different than the previous one.


is this what you mean

Sorry for the late response, yes that is what I mean.

But with a stationary reticle than a red dot on the screen.