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

ScreenGui Follows mouse pointer?

Asked by 8 years ago

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

Log in to vote
1
Answered by 8 years ago

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
0
Thank You! GeezuzFusion 200 — 8y
Ad

Answer this question