I got a script that I am tweaking but can't get it right. It is supposed to send a message if you touch a brick it ALL works except for the part at the end where it says wait(10). I want it not to show the message repeatedly if the character keeps on stepping on the part(door). Here is my script,
db = false door = game.Workspace.Door door.Touched:connect(function(hit) if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then db = true p = game.Players:GetPlayerFromCharacter(hit.Parent) m = Instance.new("Message", game.Workspace) m.Text = p.Name.." has found the door." wait(5) m.Text:Destroy() db = false end end) wait(10)
You need to check if db == false before running the code. That way, if it's true, it won't run.
db = false door = game.Workspace.Door door.Touched:connect(function(hit) if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then if db == false then --debounce check db = true p = game.Players:GetPlayerFromCharacter(hit.Parent) m = Instance.new("Message", game.Workspace) m.Text = p.Name.." has found the door." wait(5) m.Text:Destroy() db = false end end end) wait(10)