Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I make the message appear once only?

I'm currently learning functions. I don't know how I can make the message appear once only.

function PartTouch()
m = Instance.new("Message", game.Workspace)
m.Text = "Ouch! That hurts!"
wait(5)
m:Remove()
end
game.Workspace.Part.Touched:connect(PartTouch)

1 answer

Try adding a debounce! (code below)

debounce = false

function PartTouch()
 if debounce = false then
   debounce = true
m = Instance.new("Message", game.Workspace)
m.Text = "Ouch! That hurts!"
wait(5)
m:Remove()
wait(3)
debounce = false
 end
end

game.Workspace.Part.Touched:connect(PartTouch)

This discussion is preserved as it was. New answers, comments, and votes are closed.