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

How to move a Gui to mouses X and Y Coordinates?

How do I fix this, I'm trying to make the Gui be at the mouses X and Y?

local Textbox = game.StarterGui:WaitForChild("ScreenGui")
local Player = game.Players.LocalPlayer
local RunService = game:GetService("RunService")
local mouse = Player:GetMouse()

RunService.RenderStepped:connect(function()
	Textbox.Frame.TextLabel.Position = UDim2.new(0, 0, 0, 0)
	print(mouse.X, mouse.Y)
end)

1 comment

0

line 7 should be "Textbox.Frame.TextLabel.Position = UDim2.new(0, mouse.X, 0, mouse.Y)

1 answer

✓ Accepted answer

This should do:

repeat wait() until game.Players.LocalPlayer
local Textbox = game.Players.LocalPlayer.PlayerGui.ScreenGui
local Player = game.Players.LocalPlayer
local RunService = game:GetService("RunService")
local mouse = Player:GetMouse()

RunService.RenderStepped:connect(function()
    Textbox.Frame.TextLabel.Position = UDim2.new(0, mouse.X, 0, mouse.Y)
    print(mouse.X, mouse.Y)
end)

If this doesn't work, write in comments the things I changed: Textbox referred to the startergui, I changed to playerGui, then I changed UDim2.new(0,mouse.X,0,mouse.Y)

Have a great day!

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