How do I make a notification on touch with a delay

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want make a notification show up when a player touches a part with a delay.
  2. What is the issue? Include screenshots / videos if possible!
    I can’t figure out how to make a notification with a delay. With the code I used, the notification keeps showing up until I walk off the part. I want it to show up once, then wait 5 seconds and showing up again if the player is still touching the part.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried using while true do but it doesn’t work the way I want it to with wait.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

This is the script I have tried


while true do
	
	testPart.Touched:Connect(function()
		game.StarterGui:SetCore("SendNotification", {
			Title = "touched";
			Text = "touched";
			Icon = "";
			Duration = "7";
		})	
	
	end)
	
	wait(5)
	
end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

local bool = true
while true do
game.Workspace.Part.Touched:Connect(function()
	if bool then
		game.StarterGui:SetCore("SendNotification", {
			Title = "touched";
			Text = "touched";
			Icon = "";
			Duration = "7";
			
		})	
		bool = false
		task.wait(5)
		bool = true
end
	end)
	task.wait()
end

try if this work

1 Like