Creating a ScrollingMap?

Hey, I’m looking for advice -
I’m wanting to create a Galaxy map; this will work by the GUI scrolling / moving to the direction the mouse is pushing although I have no clue where to start with this.

Does anyone have any advice as to how I can achieve this?

Scrolling frame and checking mouse position minus middle of frame position… If its far enough away move the scrolling frame around

1 Like

Thanks!

Do you know how I could achieve this?

This is currently where I’m at.

Map["Boundary"].MouseEnter:Connect(function(X, Y)
	inBoundary = true
end)

Mouse.Move:Connect(function()
	if inBoundary then
		Map["Content"].CanvasPosition = Vector2.new(Mouse.X, Mouse.Y)
	end
end)

do a repeat loop and instead of by mousex and mousey do something like this

Mouse.Move:Connect(function()
	if inBoundary then
		local map = Map["Content"]--Good work of content like that, their going to add something there
		local Direction = Mouse = map.AbsolutePosition
		map.CanvasPosition = Vector2.new(map.CanvasPosition.X + Direction.X, map.CanvasPosition.Y + Direction.Y)
	end
end)
1 Like

Players.OiiTaru.PlayerGui.ScreenGui._Test:16: invalid argument #1 (Vector2 expected, got Instance) - Client - _Test:16

Receiving this error?

the equals is a minus sign, it was a typo

You might want to do it like this…

local Dampener = 5

Mouse.Move:Connect(function()
	if not inBoundary then --We dont want them to not be able to click on anything
		local map = Map["Content"]--Good work of content like that, their going to add something there
		local Direction = (Mouse - map.AbsolutePosition) / Dampener
		--Add dampener so they don't speedymgeedy
		map.CanvasPosition = Vector2.new(map.CanvasPosition.X + Direction.X, map.CanvasPosition.Y + Direction.Y)
	end
end)

Receiving this error?

16:30:00.106 Players.OiiTaru.PlayerGui.ScreenGui._Test:39: invalid argument #1 (Vector2 expected, got number) - Client - _Test:39

local Direction = (Vector2.new(Mouse.X, Mouse.Y) - map.AbsolutePosition) / Dampener
1 Like

It works nicely, but is there any way to limit it so that the Mouse is within the boundary to trigger the movement?

yes…

local Dampener = 5
local RunService = game:GetService("RunService")

RunService.RenderStepped:Connect(function()
	if inBoundary then --We dont want them to not be able to click on anything
		local map = Map["Content"]--Good work of content like that, their going to add something there
		local Direction = (Vector2.new(Mouse.X, Mouse.Y) - map.AbsolutePosition) / Dampener
		--Add dampener so they don't speedymgeedy
		map.CanvasPosition = Vector2.new(map.CanvasPosition.X + Direction.X, map.CanvasPosition.Y + Direction.Y)
	end
end)

The reason i made it so if it was out of the boundry was because if your scrolling gui has clickable stuff its going to be hard to click that if the map is moving all over the place… Also you should use RenderStepped as an activation instead of mouse.Move (I forgot to change it yesterday). Apply the dampener a bit more aswell…

1 Like