You’re setting CanCollide to false but not true afterwards. You’ll need to do this to fix that problem (I also added a debounce, and it will need to be a LocalScript inside StarterPlayerScripts for this to work):
local door = game.Workspace:WaitForChild("RAWR")
local keyword = "hi"
local player = game.Players.LocalPlayer
local debounce
player.Chatted:Connect(function(message)
if string.lower(message) == keyword and not debounce then
debounce = true
door.Transparency = 1
door.CanCollide = false
task.wait(10)
door.CanCollide = true
door.Transparency = 0
debounce = nil
end
end)
This should work now with TextChatService if you prefer it over legacy, I tested it and it works correctly on my end:
local door = game.Workspace:WaitForChild("RAWR")
local keyword = "hi"
local player = game.Players.LocalPlayer
local debounce
game.TextChatService.OnIncomingMessage = function(message)
if message.Status == Enum.TextChatMessageStatus.Success then
if message.TextSource and message.TextSource.UserId == player.UserId then
if string.lower(message.Text) == keyword and not debounce then
debounce = true
door.Transparency = 1
door.CanCollide = false
task.wait(10)
door.CanCollide = true
door.Transparency = 0
debounce = nil
end
end
end
end
when I change the scripts keyword to something like “Open” it stops working. Is there a reason for this? I fail to understand why it works with “hi” and not something like “Open”.
Also, does the “string.lower” mean that whatever the keyword is I have to type it out in lower case in order for it to work? Sorry for all the questions, I have never dealt with player message based codes before.
The keyword needs to be written in all lowercase characters, so “Open” will need to be “open”
string.lower will automatically convert all the characters in the message to lowercase versions, so even if you chat “OPEN” the door will still turn invisible and non-collidable