Hello people! I’m trying to make a map that displays all player teammates. But I have an issue, all the posts on the internet would work (I think) but half of my map is beneath (0,0,0) I think that’s why it’s behaving like this.
local mapPositionConverter = {}
local minPosition = Vector3.new(-512, 0, -512) -- bottom left
local maxPosition = Vector3.new(-1783.2, 0, -1786.1) -- top right
function mapPositionConverter.CFrameToUdim(cfValue : CFrame)
local x = (cfValue.Position.X - minPosition.X) / (maxPosition.X - minPosition.X)
local y = (cfValue.Position.Z - minPosition.Z) / (maxPosition.Z - minPosition.Z)
return UDim2.new(x, 0, y, 0)
end
return mapPositionConverter
I’m just going to remind you that both x and y have a range between 0 to 1 (wherein .5 is expected to be the center) – and these values would only work if your “dot” GUI has an anchor point of (.5, .5)
I did my own testing, and I was able to make it work with your code – and although I had to modify the y-axis code to make it work for my own usecase) – it seems to work just fine? Here’s the test code I used:
Just keep in mind that the green box on workspace is at a position of Vector3.new(0, 1, 0) – basically (0, 0) in terms of x and z.
local minPosition = Vector3.new(-5, 0, 5) -- bottom left
local maxPosition = Vector3.new(5, 0, -5) -- top right
function CFrameToUdim(cfValue : CFrame)
local x = (cfValue.Position.X - minPosition.X) / (maxPosition.X - minPosition.X)
local y = (maxPosition.Z - cfValue.Position.Z) / (maxPosition.Z - minPosition.Z)
return UDim2.new(x, 0, y, 0)
end
while true do
script.Parent.Frame.Frame.Position = CFrameToUdim(workspace.TEST.CFrame)
task.wait()
end
Please take a look in the video I sent. Roblox keeps making my streamable links to a download link, sorry for that. It’s hard for me to explain without you looking at the video.
Thank you. I thought I had it parented to the map, but now that I checked I didn’t. Really sorry for wasting your time. I’ll try it now, I’m pretty sure this would fix it as it’s in Scale and not Offset.