# Location map with live player position

Basically, I’m programming a map that will show the live position of the player upon opening (this includes the direction the player is looking and their current position in the world.

Here’s how it currently works:
https://gyazo.com/1ebbacd2e4c37c503394ce45c21004c9

As you can see real time positioning works and so does the rotation of the marker relative to the player’s look direction.

## The problem

The issue I’m facing is that I need the map to be sized using Offset, and not scale. The position however is scale so that it is at the center of the screen.

Why is this relevant? I need the player marker to move at such a speed that it accurately reflects on the map where the player is in game regardless of the player’s screen size. I’m not sure how to achieve this - as you see in the gif the player marker moves extremely fast and isn’t accurate at all. On top of this it does not accurately reflect where the player spawns in.

## My code

``````local ScaleFactor = 2.85

RunService.RenderStepped:Connect(function()
PlayerMarker = LocationsMap:WaitForChild('LocationMarker')

local CharPosition = HumanoidRootPart.Position
local XPosOffset = (CharPosition.X / ScaleFactor)
local YPosOffset = (CharPosition.Z / ScaleFactor)

PlayerMarker.Position = UDim2.new(XPosOffset, 0, YPosOffset, 0)

local LookDir = Camera.CFrame.lookVector

PlayerMarker.Rotation = -FinalRotation
end)

``````

### Properties of the map (which is an ImageLabel)

Any help would be highly appreciated.

4 Likes

Find the stud points in the world where you map ends, and get the percentage of the player across that distance. This way you have relative position in the world that you can put as the scale position of the player marker.

2 Likes

By stud points you mean the coordinates of the four corners of the map? I’m not sure I quite understand what you mean.

Yes, the four corners of the map in the world.

For example: Your map is 100 studs by 100 studs, with a center point of 50,50. Farthest left X coordinate is -50, farthest right is 50. The farthest Y coordinates are also -50, and 50.
If the player’s position in the world is (25,25), you find their scalar position by dividing their distance from the farthest leftward points by the size of the world. So you would divide 75 (the difference between -50 and 25) by 100 (the total size of the map) for both X and Y. This will give you a scalar position of (.75,.75)

2 Likes

Okay - here’s the issue with that. The game is split into multiple universe places and the only part of the map that is relevant is of the place the player is at.

For example, one of the places is just that red square, but the map shows much more than that. Should I just get the corner points of that red square then?

Yes, use the points of the world in that place, and make a frame that covers that same space in the UI. Parent the player position marker to this frame that way the position you set to the marker will be relative to that area.

3 Likes

hi, i have played your game and is really good, i have the same problem if you fix this can you please tell me how u got this?