Minimap problem

Hello so, I edited a bit of a code someone made, to make it work with mine, but as you can see in first picture, there’s 2 Green points, one at the minimap, and other on street, when I move there, it should mark where is marked at minimap but…


This happens:
At green is where it should be, at red is where I am, (minimap)

This is code:

local mapFrame = script.Parent.MapFrame.ImageLabel
local MAP_STUD_SIZE = 2404


game:GetService('RunService').RenderStepped:Connect(function()
local ORIGIN = script.Value.Value
local centerPos = game.Players.LocalPlayer.Character:WaitForChild('HumanoidRootPart')
local diff = centerPos.Position - ORIGIN
local mapSize = script.Parent.MapFrame.ImageLabel.Size.X.Offset
			local newSize = math.floor(mapSize + (script.zoom.Value * 1 - mapSize) * 0.02)
			mapFrame.Position = UDim2.new(0.5, diff.Z / MAP_STUD_SIZE * newSize, 0.5, -(diff.X / MAP_STUD_SIZE) * newSize)
			mapFrame.Size = UDim2.new(0, newSize, 0, newSize)
end)

This are values
image
^ zoom
image
^ center pos

How can I fix this?
I tried rotating the minimap but the clipdescendants broke, and still… wouldn’t work

I did Position at diff
30chars

I’ve made a mini map module which might be helpful, Minimap module - Minimap creator (you could even skim through to see how it works), I’m going to assume you would rather make your own custom minimap, if so, what’s the size of your image(the size of the original image in pixels) and the size of your map (X and Z)?

Note:
Instead of doing game.Player.LocalPlayer.Character:WaitForChild("HumanoidRootPart"), each frame, you could create a variable called HumanoidRootPart and update it each time LocalPlayer.CharacterAdded is fired, it should reduce resource consumption.

2 Likes

I’ll check it out, thank you!
The map size UDim2 is: {0, 151},{0, 151}
And the original image is this:


I don’t exactly know
I don’t kinda want your method, I mean, is lovely… but it’s not exactly what I want, and the map has many parts, so imagine… lol
I just need to know how to set this up to make it go to correct position

local mapFrame = script.Parent.MapFrame.ImageLabel
local MAP_STUD_SIZE = 2404
local centerPos= game.Players.LocalPlayer.Character:WaitForChild('HumanoidRootPart')

game.Players.LocalPlayer.CharacterAdded:Connect(function()
	centerPos = game.Players.Character:WaitForChild('HumanoidRootPart')
end)

game:GetService('RunService').RenderStepped:Connect(function()
local ORIGIN = script.Value.Value
local diff = centerPos.Position - ORIGIN
local mapSize = script.Parent.MapFrame.ImageLabel.Size.X.Offset
			local newSize = math.floor(mapSize + (script.zoom.Value * 1 - mapSize) * 0.02)
			mapFrame.Position = UDim2.new(0.5, diff.Z / MAP_STUD_SIZE * newSize, 0.5, -(diff.X / MAP_STUD_SIZE) * newSize)
			mapFrame.Size = UDim2.new(0, newSize, 0, newSize)
end)

Since you’re not using scale, you could use 2 offset constants which will be added onto the offset, and as you’re also planning on changing the size of the map(zoom), you might also need to work out a ratio to multiply the offset by when you change the size of of the map, it’s not the most efficient solution in my opinion but, if you’re going for functionality, it should (hopefully) do the trick.