https://gyazo.com/5d6ebac64e63abb0ba550ded9478bf17
Ignore this and read my reply instead
I reckon the problem is the fact that old_mouse_pos
is only being updated on InputBegan
, so as long as the mouse is above where the player first clicked, regardless of what direction the mouse is moving afterward, it will keep moving in that one direction as long as it’s above or below where the player first clicked to drag.
local function InputBegan(input, process)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
move_map = true
old_mouse_pos = UIS:GetMouseLocation()
end
end
local function InputChanged(input, process)
if input.UserInputType == Enum.UserInputType.MouseMovement then
if not move_map then return end
local mouse_location = UIS:GetMouseLocation()
local Direction = (Vector2.new(-(mouse_location.X - old_mouse_pos.X), -(mouse_location.Y - old_mouse_pos.Y)) - map.AbsolutePosition) / dampener
map.CanvasPosition = Vector2.new(map.CanvasPosition.X + Direction.X, map.CanvasPosition.Y + Direction.Y)
end
end
local function InputEnded(input, process)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
move_map = false
end
end