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

ScreenGui Follows mouse pointer?

Is there a way to make a Frame in a ScreenGui follow the player's mouse Pointer? I came up with this but it's acting weird

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

while wait() do
	script.Parent.Frame.Position = UDim2.new(0,mouse.Hit.x,0,mouse.Hit.y)
end

1 answer

✓ Accepted answer

Setting the frame's position to the mouse's position would cause the upper-left corner of the frame to be where the mouse is. I am not entirely certain if this is what you want but what you were trying to do is position the frame based upon where the mouse is pointing in the 3D world.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

while wait() do
    script.Parent.Frame.Position = UDim2.new(0, mouse.X, 0, mouse.Y)
end

1 comment

0

Thank You!

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