Keep getting infinite yield on line 6. I don't know why is this occurring, can someone please fix and explain it to me? Thanks

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

local gui = workspace["Water Dispenser"]:WaitForChild('WaterGui')

local WaterGui = script.Parent.Parent:WaitForChild('WaterGui')
local TextLabel = WaterGui:WaitForChild('TextLabel')

game:GetService('RunService').RenderStepped:Connect(function()
	local X = Mouse.X
	local Y = Mouse.Y
	
	if Mouse.Target then
		if Mouse.Target.Name == "WaterGui" then
			TextLabel.Position = UDim2.new(0,X,0,Y + 50)
			TextLabel.Visible = true
		else
			TextLabel.Visible = false
		end
	end
end)

2 comments

0

An infinite yield means it keeps waiting for "WaterGui", but Roblox isn't detecting that it's there, so it just keeps waiting.

0

I fixed it it had an extra .Parent. Thanks!