The best method that I have found of how to make a minimap in Roblox is by using raycasting. I made a script where rays are shot from the sky down to the map; the first part the ray lands on, a tiny pixel is added to a 500x500 frame with the same color as the part. This is the script I came up with.

function castRay(width, length, startLength, dim) --Width is the length of the map in X, length is the length of the map in Z, startLength isn't important, and dim is how big each ray is.
	local player = script.Parent.Parent.Parent.Parent
	for i = startLength, length do
		for j = 0, width do
			wait(.0000000000001) --Even with this wait, it still takes AGES
			local point = Instance.new("Part", game.Workspace) --Creating a part to represent points on the minimap
			point.Name = i+j+1
			point.Size = Vector3.new(dim, dim, dim)
			point.Position = Vector3.new(560.5-j*dim, 300, 942.5-i*dim)
			local ray = Ray.new(point.CFrame.p, (Vector3.new(point.Position.X, -10, point.Position.Z)-point.CFrame.p).unit
			*400) --Creating a ray that aims directly down onto the point
			local part, position = workspace:FindPartOnRay(ray, player.Character, false, true) --Locating the part the ray lands on
			if part ~= nil then
				local dot = Instance.new("Frame", script.Parent) --Creating a new point for the minimap
				dot.Name = point.Name
				dot.BackgroundColor3 = Color3.new(part.Color.r, part.Color.g, part.Color.b) --Making the color the same color as the part
				dot.BorderSizePixel = 0
				dot.Size = UDim2.new(0, 1, 0, 1)
				dot.Position = UDim2.new(0, j, 0, i)
			end
			point:Destroy() --Destroy the part to reduce lag
		end
	end
end

castRay(499, 499, 0, 4) --Activating the function. The minimap is 500 by 500.

The problem is that this makes my computer lag a whole lot. It's also a very time consuming process. I tried making the dim value 10 instead of 4, which would reduce the resolution of the minimap thus reducing the lag and amount of time required, but then the outcome just looked messy.

I want to be able to make a minimap with good resolution without having to deal with lag and preferably without having to deal with hours of waiting. How can I accomplish this? The entire map is 2000 by 2000 studs by the way.

1 comment

0

First off, good job on proposing the method. As to your question, i would try dividing the job by having as many instances of the app as you have cores on your cpu. I would scan 1/n th(where n is the number of cores on your cpu) of the map on each individual instance of the app (the number of instances, again, should be n). I expect a much faster response time.