How do I make a door with a randomly generated code?
I have been going slightly crazy trying to make this work.
Goal:
I have made this script that is supposed to create a random code. Then, if a player types that code in chat, the door gets destroyed
Problem:
This code won't do anything. It doesn't give me an error message and there is no script errors according to Roblox studio. I have tried to use a bunch of other chat door scripts as well, but I came to the same problem.
Here's a cut version of my script (Cut out the parts that aren't giving me problems)
01 | local code = math.random( 100000 , 999999 ) |
03 | game.Players.PlayerAdded:Connect( function (p) |
04 | p.Chatted:Connect( function (message) |
05 | if message = = code then |
06 | game.Workspace.Secret.SecretDoor:Destroy() |
Note: This script works if line 5 has quotations around it, but if I did "code" then it would be looking for the word code, not the local code.
Thank you for reading, hope I can find a solution to this infuriatingly small script I've been working on for 2 days :)