Move image with mouse problem

I was just playing around with the background effects and I I can’t get the image not go over as you will see in this gif…
I don’t know how do I limit the position it can move so any help could help me

I have to still make the image bigger, but it will be too big to make those empty spaces dissapear

https://gyazo.com/a132eb32cc51293cd24e9613c8350efc

local mouse = game.Players.LocalPlayer:GetMouse()
local cam = game.Workspace.CurrentCamera

function mover()
	local Center = Vector2.new(cam.ViewportSize.X/2, cam.ViewportSize.Y/2)
	local MoveVector = UDim2.new((mouse.X-Center.X)/1000,0, (mouse.Y-Center.Y)/1000, 0)
	script.Parent.Position = MoveVector
end

game:GetService("RunService").RenderStepped:Connect(mover)
1 Like

You can use math.clamp to limit the maximum the frame can move on the x and y axis.

1 Like

ah… I see that I am very dumb. Thank you very much tho