So, I have this script to, when the player hovers over the part, for a gui to show then always move to the player's mouse position until the player gets to far or stops hovering over the part. LocalScript in Frame

wait(1)

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local target = mouse.Target
local gui = script.Parent

gui.Visible = false

mouse.Move:connect(function()
	if target.Name == "lookpartforchest" and (game.Workspace.lookpartforchest.Position - player.Character.Torso.Position).magnitude <= 12 then
		gui.Visible = true		
		repeat		
		gui.Position.X = mouse.X
		gui.Position.Y = mouse.Y
		wait(0.01)
		until
		target.Name ~= "lookpartforchest" or  (game.Workspace.lookpartforchest.Position - player.Character.Torso.Position).magnitude >= 12
		gui.Visible = false
	elseif not target then
		gui.Visible = false
	end
end)

Sorry if the error is so obvious, I was tired while making this and haven't used mouse.X and mouse.Y before.

1 comment

0

How is it not working as expected? (At a glance, putting a loop inside the event handler may have something to do with it.)