You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I don’t want any errors
What is the issue? Include screenshots / videos if possible!
Errors occur and the error is about a coroutine and resuming a non suspended one
-- When it first runs it works fine. But the second times these errors pop up
-- cannot resume non-suspended coroutine; Error occurred while calling TextChatService.OnIncomingMessage: cannot resume non-suspended coroutine
local success, result = pcall(function()
local systemchannel = textchatservice:WaitForChild("TextChannels"):FindFirstChild("RBXSystem")
systemchannel:DisplaySystemMessage("Wait: "..tostring(amount).." seconds until you can send another message.")
return systemchannel
end)
first, there are no present errors with this script and second I trying to make that when a player holds a tool and chats a custom chat command, a remote event will fire. After the event is fired successfully, there will be a debounce of 30 s until the player can chat the custom chat command and it will display a system message of waiting 30s.
Also: The custom chat command is the text from the player that is typing in the chat input bar
I see, to solve the error you have, try something like this:
local systemchannel = textchatservice:WaitForChild("TextChannels"):FindFirstChild("RBXSystem")
if systemchannel and systemchannel:IsA("TextChannel") then
systemchannel:DisplaySystemMessage("Wait: "..tostring(amount).." seconds until you can send another message.")
else
print("No text channel found :(")
end