Hello, I'm trying to make a demo script, that makes it if you hover over a model named "Noob" a Frame will follow your mouse. I've tried mouse.Hit and Mouse.Target but no matter what the script i'm working with isn't working. Can someone please review it?

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Gui = player.PlayerGui:WaitForChild("ScreenGui")

function hover()
	print(mouse.Target.Parent.Name)
	if mouse.Target.Parent.Name == "Noob" then
		Gui.Frame.Position = UDim2.new(0, mouse.X, 0, mouse.Y)
	end
end
mouse.Move:Connect(hover)

9 comments

0

Can you define which part isn't working? Does it recognize that there is a model named "Noob"? Is it the GUI that isn't moving? Or are your declarations failing?

0

What is the error?

0

The Gui Isn't moving when I hover over it. As a control, I'm going to test this with a part rq.

0

And it still doesn't work. Btw after like 5 seconds the script crashes and says:

0

And it's not crashing anymore cause I moved it to StarterGui

0

Is this in a server script?

0

Nope. Local

0

U can't use local scripts in workspace

0

its not in workspace. Its in StarterGui