#Debounce.
You could be using debounce, this way people will only be able to do a certain action on a specific amount of time.
Debounce is structured with booleans, and in your case you would have to do the following:
Define a true boolean.
Add an if statement which will return nil if the previous boolean hasn't met thetrue condition.
Make the previous boolean false.
Wait for a specific time.
Make it true again.
#Practice:
local canClick = true
local part = script.Parent
part.Parent = game.Workspace
local ChatService = game:GetService("Chat")
function Clicked(player)
if not canClick then return end
canClick = false
ChatService:Chat(part, ("Hi there "..player.Name), "Red")
wait (2)
ChatService:Chat(part, ("How can i help you?"),"Red")
wait(1)
canClick = true
end
script.Parent.ClickDetector.MouseClick:Connect(Clicked)
Another fact is that connect is deprecate. Use Connect instead. You can read about deprecated items here.
1 comment
Thanks!