Dragging a Map with your Mouse

Hey everyone,
I have wanted to achieve move the map with your mouse, like in shown in the video from ERLC.


I’m using a picture of the map rendered in a Viewport Frame.
Maybe I am just bad at searching, or nobody really had a problem with it.
I hope somebody can help me.

3 Likes

I assume that the origin of the ViewportFrame is being translated by mouse movement. It is like being able to control the position of the camera man.

1 Like

That is basically the question: How do I track the mouse Movement and translate it into camera Movement.

You can listen for MouseButton1Down event (on a image button that covers the viewport frame) then use mouse.Move

I tought, Mouse.Move is only an event, that fires when the mouse is moved.

It is, but if you combine it with MouseButton1Down you can detect click and drag, just make sure you disconnect the event once the mouse is let up (MouseButton1Up)

So, I have made this messy Script.

local Maus = Player:GetMouse()

Maus.Button1Down:Connect(function()
	local Move = Maus.Move:Connect(function()
		print(Maus.Move)
	end)
	Maus.Button1Up:Connect(function()
		Move:Disconnect()
	end)
end)

But in Output, it only gives me a Signal and no Data to work with.
Signal