How do you stop spamming on touch?

Hello, I’m making a script where when you touch a part a message shows up. But when you press it, it spams the gui message.

Code:

local Players = game:GetService("Players")

local part = script.Parent
local function onTouched(part)
	local player = Players:GetPlayerFromCharacter(part.Parent)
	if not player then return end
	print(player.Name)
end
part.Touched:Connect(onTouched)

Any help is appreciated, I just need to know how to make a GUI pop up ONCE and maybe a debounce when you touch the part.

Fixed! Just had to change something!

A simple wait(1) would have done the trick honestly.

Yeah, that’s what I forgot, so I added it.

1 Like