Need help with dialogue script

I have a dialogue script, however, for some reason when I move far from the touch part, For example, around 500 studs,
there is an error that says that the part does not exist even though it already is there, I have no idea how to fix it. But it does not seem to interfere with the script that much, it is very annoying to see a lot of errors in the output log, the script is listed below

local touchpart = workspace["Floor 7"] :WaitForChild("touchpart16")
local player = game.Players.LocalPlayer
local text = player.PlayerGui.Dialogue["Floor 7"].Text1.TextLabel
local canhit = true

touchpart.Touched:Connect(function(hit)
	if canhit == true then
		local name = hit.Parent.Name
		if hit and hit.Parent:FindFirstChild("Humanoid") then
			text.Visible = true
			for i,p in pairs(game.Players:GetChildren()) do
				if p.Name == name then
					canhit = false
					text.Visible = true
					wait(2)
					text.Visible = false
					wait(900000000000000)
					canhit = true
				elseif p.Name ~= name then
					text.Visible = false
					break
				end
			end
		end
	end
end)

THE ERROR

touchpart16 is not a member of Floor 7
1 Like

Why are you using wait() for so long? Just curious.

wait(900000000000000)

I used the long wait() timer just because of the player continuously stepping onto the dialogue part and making the GUI overlap.

Misleading error. If the error is x is not a valid member or y, it’s caused by y.x. However you’re using WaitForChild, which on the case of it not existing it throws a warning and yields the whole script. Check if the source is correct.

Do not use Touched, I recommend using ZonePlus: