Need help with making a "points" gui script

Hello everyone!

I want to make some sort of a points map on your screen, that will show distance to an object, etc.

The screenshot is an example of what I want to make:
unknown

The points on the screenshot move across the screen depending on the players camera rotation or position, and shows the amout of studs from the player to the point.

I would make it myself, but currently I don’t understand how to.

First off, let’s start with the points them selves, this can be achieved with a Billboard Gui. You can use properties such as, AlwaysOnTop and MaxDistance, to make sure that it is visible from very far away. It is also important to note that the text label will be separate from the point Gui.

Now for the programming behind the points. As you said, you want it to show the distance between the Player’s character and the point, this can be done easily by using Magnitude. The text label that you created earlier will display the magnitude.

If you have any more questions or are having trouble doing this, feel free to DM me for more information.

1 Like

I knew that I have to use the billboard gui, but:

1. I can’t realize how to make it show the distance.
LocalScript in StarterGui:

local plr = game.Players.LocalPlayer
local char = plr.Character
local humroot = char.HumanoidRootPart

local runService = game:GetService("RunService")

local point = workspace:WaitForChild("point")
local magtext = point.BillboardGui.Magnitude


runService.RenderStepped:Connect(function()
	local dist = (point.Position - humroot.Position).Magnitude
	magtext.Text = dist
end)

The problem is, it doesn’t change the text at all.

2. I can’t make that it will show at the screen, when I don’t look at it directly.

Are there any errors in the output? Also the problem could be that you named it “Magnitude”. When you reference it in the text roblox might think that you mean Magnitude as in the way to find distance between objects, not the text label. Maybe try changing the name?

Alright, so I fixed the problem.

But how do I remove the numbers after the “.” and keep only 4?
image

math.floor removes decimal points.

runService.RenderStepped:Connect(function()
	local dist = (point.Position - humroot.Position).Magnitude
        local roundedNumber = math.floor(dist + 0.5)
	magtext.Text = roundedNumber
end)

Use math.round it’s as simple as this math.round(number).

I recommend math.round instead of math.floor for this scenario.

Alright, now I want to make it like:

When I look at it, it just displays the amount of feet:
image

But when I’m not looking at it, it’s gonna be something like:
image

Basically it shows the same gui, but with an arrow that faces the position of the part that contains the actual billboard gui.

The thing is we can make any 3D parts easily face something by using the second CFrame property, if you just put in the position value of that part then the 3D part’s look vector changes to face it. However, implementing that in 2D space will be different.

Update:

Ok I got a pretty good idea, try this, make a part (Let’s call this part A) and put a surface gui on it with the arrow. Then insert a second part (Let’s call this part Part B) on the ground beneath Part A. Now, insert a script in Part A and make it contain the following:

PartA.CFrame = CFrame.new(PartA.Position,PartB.Position)

What the above code basically does is it sets the position property equal to the part itself, then it sets the second perimeter equal to the position of the part it needs to face, which in this case is the part beneath it. So, in theory it should rotate to face part B and then set the arrow to face it. Please note that you will have to hit and try to find the perfect position and rotation for the initial Part A.

Maybe I should use offset? If I should, then I don’t know how to code it.

Actually, there’s a problem with this, it doesn’t set it in terms of the player’s position, but only the position of the part, so the arrow will always face down. We need to somehow fix that.

I want to achieve something like in this video with these points on the screen:

Basically, it resizes and moves the points depending on the position.

I think you should forget the arrows for now, I think that displaying magnitude is good enough at the level you are currently at, never try to over do it. It does nothing but make you lose motivation, I can tell you don’t have much experience yet, but not to worry! Once you start making more projects you’ll learn more stuff and eventually even get to this point!

2 Likes