Hi! I used @JohhnyLegoKing 's script for my puzzle game. It works without /e, but I don’t want other players to see the exact code, and it doesn’t seem to work with /e. Any tips?
could you provide more details about what script you are using? i searched his profile but I’m not sure which script of his you are referring to.
chances are his door uses old chat system so it just doesn’t work or something
local door = game.Workspace:WaitForChild("Door1")
local keyword = "37:53"
local player = game.Players.LocalPlayer
local debounce = false
game.TextChatService.OnIncomingMessage = function(message)
if message.TextSource and message.TextSource.UserId == player.UserId then
print(string.lower(message.Text))
if string.lower(message.Text) == keyword and not debounce then
debounce = true
door.Transparency = 1
door.CanCollide = false
end
end
end
When i add a /e to the keyword, it doesn’t work.
My door uses the modern chat system btw
-
It’s incredibly frustrating to hear that your door utilizes a modern chat system, as it seems to prioritize technology over genuine human interaction. This reliance on digital communication can lead to misunderstandings and a lack of personal connection, which is essential in any meaningful exchange.
-
The fact that you mention this system as a point of pride is disappointing. It suggests a complete disregard for the value of face-to-face conversations and the richness they bring to our interactions. Relying solely on a chat system diminishes the importance of empathy and understanding that can only be conveyed through direct communication.
-
Ultimately, this approach feels like a step backward in fostering real relationships. Instead of embracing the warmth of personal engagement, it appears that convenience has taken precedence, leaving me feeling disheartened and frustrated by the lack of authenticity in our interactions.
What do you man by that… I don’t really have much other options because legacy chat system got removed.
is this client script, and if so then have you tried printing the messages text and seeing if /e messages even send at all?
Yes it’s a client script, yes i’ve tried printing it, no it did not send.
on the server use Player.Chatted and do the same print method and see if it prints /e messages. player.chatted works on the server with textchatservice.
is this chatgpt??
btw, if you’re needing a fix, try do several “ELSE” statements.
like,
if string.lower(message.Text) == keyword and not debounce then
debounce = true
door.Transparency = 1
door.CanCollide = false
else
print("not string.lower")
end
reply to me when you’re ready mr sal
Hello there! To clarify, are you operating the chat to open the door? If so, here is the video I used in creating the command: https://www.youtube.com/watch?v=HuLfmCvbrts
If you only want the command itself, ignore like half of the video. You’re welcome!
This is my method, but it’s not the best.
It requires three elements:
- Server Script (ServerScriptService)
- Local Script (StarterGui or other)
- Remote Event (ReplicatedStorage)
The ServerScript
contains the code that fires the RemoteEvent
to open the door only for the person that chatted the keyword. When firing the event, I used the parameter door_location
, which is the location of the door you want to open i.e. game.Workspace.Door1
.
Click to View ServerScript
local keyword = "/e 37:53"
local debounce = false
-- Get all individual player messages
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
-- If the player's message matches the keyword
if string.lower(message) == keyword and not debounce then
debounce = true
-- Fire the event to the specific player AND the location of the door part
-- because there may be multiple doors with different codes if you want
game.ReplicatedStorage:WaitForChild("OpenDoor"):FireClient(player, game.Workspace.Door1)
end
end)
end)
A RemoteEvent
is used because the script runs on the server. To open the door for just the player that chatted the message, the remote event firing activates the local script that opens the door.
The LocalScript
contains that code that runs when the RemoteEvent
is fired to open the door. Remember to bring in the door_location
parameter to choose which door you want to open.
Click to View LocalScript
game.ReplicatedStorage:FindFirstChild("OpenDoor").OnClientEvent:Connect(function(door_location)
door_location.Transparency = 1
door_location.CanCollide = false
end)
When the player chats the message /e 37:53
, the player will see the message “You do not own that emote.”, which the other players can’t see, which hides the code from them. Because the Player.Chatted
event was used in a ServerScript
, the door still opens even when the “You do not own that emote.” error appears after the player enters the code.
I hope this helps!
Now that I know which script you were referring to, I can try to fix your problem
First things first, I’d recommend that you avoid using /e
for the door’s code, since it would conflict with the default emote command, and you’ll get an annoying You do not own that emote
error in the chat window (which is a big pain to get rid of). If you insist on using it anyway, then you’ll need to use the RBXEmoteCommand
’s Triggered
event and do something like this:
-- LocalScript in StarterPlayerScripts
--!strict
local Players = game:GetService("Players")
local TextChatService = game:GetService("TextChatService")
local CODE = "open" -- Set this value to the code that needs to be used to open the door
local player = Players.LocalPlayer:: Player
local textChatCommands = TextChatService:WaitForChild("TextChatCommands")
local rbxEmoteCommand = textChatCommands:WaitForChild("RBXEmoteCommand"):: TextChatCommand
local function OnTriggered(textSource: TextSource, unfilteredText: string)
if textSource.UserId == player.UserId then
local lowercase = string.lower(unfilteredText) -- This will make the command case insensitive
local words = string.split(lowercase, ' ') -- This will separate the '\e' part from the code
table.remove(words, 1) -- This will remove the '\e' part from the "words" array
local code = table.concat(words, ' ') -- Convert the "words" array back to a string
if code == CODE then
print("Correct code entered!")
else
warn("Incorrect code entered")
end
end
end
rbxEmoteCommand.Triggered:Connect(OnTriggered)
Second, if you’d like to hide the code from clients (which is a good thing to do, so that exploiters won’t be able to read the code from the LocalScript), you’ll need to do something a bit similar to what @TheMushroomOne said:
- Create a
RemoteEvent
inside ofReplicatedStorage
(I named mineCodeDoorOpenRequest
) - Edit the LocalScript I provided above so that it looks like this:
-- LocalScript in StarterPlayerScripts
--!strict
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TextChatService = game:GetService("TextChatService")
local codeDoorOpenRequest = ReplicatedStorage:WaitForChild("CodeDoorOpenRequest")
local player = Players.LocalPlayer:: Player
local textChatCommands = TextChatService:WaitForChild("TextChatCommands")
local rbxEmoteCommand = textChatCommands:WaitForChild("RBXEmoteCommand"):: TextChatCommand
local function OnTriggered(textSource: TextSource, unfilteredText: string)
if textSource.UserId == player.UserId then
local lowercase = string.lower(unfilteredText) -- This will make the command case insensitive
local words = string.split(lowercase, ' ') -- This will separate the '\e' part from the code
table.remove(words, 1) -- This will remove the '\e' part from the "words" array
local code = table.concat(words, ' ') -- Convert the "words" array back to a string
codeDoorOpenRequest:FireServer(code) -- Send the code to the server
end
end
rbxEmoteCommand.Triggered:Connect(OnTriggered)
- Add a server script to ServerScriptService, and use this for its code:
-- Server Script in ServerScriptService
--!strict
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CODE = "open" -- Set this value to the code that needs to be used to open the door
local codeDoorOpenRequest = ReplicatedStorage:WaitForChild("CodeDoorOpenRequest")
local function OnCodeDoorOpenRequest(player: Player, code: string)
if code == CODE then
print(player.DisplayName.." used the correct code!")
else
warn(player.DisplayName.." failed to open the door, due to using the wrong code")
end
end
codeDoorOpenRequest.OnServerEvent:Connect(OnCodeDoorOpenRequest)