ok so this works but when i move my mouse off of the game frame it prints that target is nil
local mouse = game.Players.LocalPlayer:GetMouse() mouse.Move:connect(function() if mouse.Target.Name=="derpbrick" then game.Players.LocalPlayer.PlayerGui.herpy.Position=UDim2.new(0,mouse.X,0,mouse.Y) end end)
Open up the Output window and you'll notice an error occurred: 22:36:05.540 - Players.Player1.PlayerGui.LocalScript:3: attempt to index field 'Target' (a nil value)
The problem here is that you're assuming that mouse.Target is an object. When you move your mouse over the sky, there's nothing that the mouse is pointing to, so mouse.Target becomes nil. When you try to get the value of the "Name" property of nil, of course it's going to throw an error!
Before checking the name property, you should make sure that mouse.Target exists.
if (mouse.Target ~= nil and mouse.Target.Name == "derpbrick" then game.Players.LocalPlayer.PlayerGui.herpy.Position=UDim2.new(0,mouse.X,0,mouse.Y) end