Help with making a secret code!

Alright, so basically i have a piece of code that loads things into the game.

Currently, i dont really know how to make it so that everyone can say it, because i want to make a secret item you can unlock by saying something. I know how to do everything except making it so that everyone can say it. Here is my current script.

function onChatted(msg, speaker)

source = string.lower(speaker.Name)
msg = string.lower(msg)
if msg == “secret-code-112-3-4-5-” then
–Code Here
require(ID HERE ID HERE).load(“player name”)
–Code Here
end
end

function onPlayerEntered(newPlayer)
newPlayer.Chatted:connect(function(msg) onChatted(msg, newPlayer) end)
end

game.Players.ChildAdded:connect(onPlayerEntered)

1 Like

Can you clarify what you mean when you say “make it so that everyone can say it”?

Do you mean you want to give the secret item to the player if they say it, or allow the player to get the item when they say it? From looking at your code, I’m pretty sure you already have an event that fires when a player says something, unless it doesn’t work?

Also, next time you want to write out a code, use `` at the start and end of your code so it looks more organized.

print(“yes”)

1 Like

someone messaged me solving the problem, but thanks for the feedback anyway

Oof, I didn’t realize the title change. Good luck with whatever you are working on!

1 Like

Thanks you very much! I hope you have good luck with whatever you are also doing!

1 Like

P.S.

--Using this
local looks = "Much better";
because = "You get formatting for Lua code";

```lua
–code
```

1 Like