script.Parent.MouseEnter:Connect(function() not working

for some reason this doesn’t work

script.Parent.MouseEnter:Connect(function()
	script.Parent.Frame.Visible = true
	while true do
		script.Parent.Frame.Position = UDim2.new(game.Players.LocalPlayer:GetMouse())
		wait()
	end
end)
1 Like

Add a print and see before the loop and see if it does print, if it doesn’t print that means your GuiObject is no Visible or in other terms is no receiving any Input.

GetMouse() returns an Instance, not the UDim2

https://developer.roblox.com/en-us/api-reference/function/UserInputService/GetMouseLocation

and how would i fix that???

https://developer.roblox.com/en-us/api-reference/function/UserInputService/GetMouseLocation

You could probably use the code example provided in this API Reference, as it converts a Vector2 into a UDim2 datatype

local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local gui = script.Parent
local screenGui = gui.Parent
screenGui.IgnoreGuiInset = true
mouseLocation = UserInputService:GetMouseLocation()
gui.Frame.Position = UDim2.fromOffset(mouseLocation.X, mouseLocation.Y)

local function moveGuiToMouse()
	mouseLocation = UserInputService:GetMouseLocation()
	gui.Frame.Position = UDim2.fromOffset(mouseLocation.X, mouseLocation.Y)
end
 
RunService:BindToRenderStep("moveGuiToMouse", 1, moveGuiToMouse)

what: