Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 7 years ago

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?

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? BlueTaslem 18071 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

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

0
It depends where your mouse is parented ofc TheLowOne 85 — 7y
Ad

Answer this question