Hello, I need help to make a minimap that can be moved with the mouse.
What I would like to do is that when the player click on the minimap, and moves his mouse, the map will also move with his mouse.
Can someone explain me how to do something like that please?
Create LocalScript inside your frame where minimap is located and paste the script inside it.
Script:
local UserInputService = game:GetService("UserInputService")
local gui = script.Parent
local dragging
local dragInput
local dragStart
local startPos
local function update(input)
local delta = input.Position - dragStart
gui.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
end
gui.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
dragging = true
dragStart = input.Position
startPos = gui.Position
input.Changed:Connect(function()
if input.UserInputState == Enum.UserInputState.End then
dragging = false
end
end)
end
end)
gui.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
dragInput = input
end
end)
UserInputService.InputChanged:Connect(function(input)
if input == dragInput and dragging then
update(input)
end
end)
I hope this will help.
it’s a viewportframe So it’s a camera
What I want is to be able to navigate in the minimap, not move the gui
Can you pretty please tell us what the minimap is, maybe an Image label?
It is a viewportframe, with the parts of the map in it, and a camera in the viewportframe.
I don’t know how to do it, can you help me please?
just find a way to move the camera when dragging on the viewportframe, and also im just here to give tips, as the rules say that i cant just feed you scripts. sorry!
It was complicated but I finally finished, I was inspired by the script of @MasterStudioWorld and I modified it to adapt it to my system, it works thanks
What did you change or can you send the script here? Many people are looking for this including me, and your resource would be very useful.