local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
script.Parent.MouseButton1Click:Connect(function()
if mouse.Target then
script.Parent.Position = UDim2.new(0,mouse.X,0,mouse.Y)
end
end)
My problem: When i click the button goes off the screen.
Seems like you’re using the Offset property, couldn’t you use the Size instead?
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
script.Parent.MouseButton1Click:Connect(function()
if mouse.Target then
script.Parent.Position = UDim2.new(mouse.X, 0, mouse.Y, 0)
end
end)
Definitely not, that would make it go ScreenWidth * MouseX pixels across, which for reference is about this number with the mouse at the middle on a 1920 monitor: 1843200