Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you make an X and Y offset directly on a mouse?

CODE ( very easy ) :

mouse.Move:connect(function()
short.Position = UDim2.new(0,mouse.X,0,mouse.Y)
end)

Since I am putting mouse.X and mouse.Y in the offset it throws the mouse and frame in a different place.

EXAMPLE :

http://prntscr.com/bt11pr

Now I understand this is happening becuase of the offset, but I need it to stay as offset, if I were to use scale it would mess everything up. Any ideas on how I can fix this?

1 comment

0

This code works, if short is parented directly to the ScreenGui. Can you explain the hierarchy of GUI objects you have, and what precisely you need to accomplish?

1 answer

It looks like you are using GetMouse() object, maybe not I do not know.

A better way could be

local plr = game:GetService("Players").LocalPlayer
local uis = game:GetService("UserInputService")
local s = Instance.new("ScreenGui")
s.Name = "ok"
s.Parent = plr.PlayerGui

local f = Instance.new("Frame")
f.Size = UDim2.new(0, 10, 0, 10)
f.Parent = s

uis.InputChanged:connect(function(i)
	f.Position = UDim2.new(0, i.Position.X, 0, i.Position.Y)
end)
--works fine for me, directly covers the mouse

or if you have a frame already existing as a main frame, you could use frame.InputChanged

1 comment

0

It depends where your mouse is parented ofc

This discussion is preserved as it was. New answers, comments, and votes are closed.