How would I create a door that needs morse code to open it?

Hello, I basically want to recreate this::

I tried to do it myself, but every time it fails somehow, I’d appreciate some help on this!

– once you figure out the morse code a door opens
– i found this script from the creator of identity fraud:: Text to MorseCode Encoder - Pastebin.com

1 Like

First you need to set a sound which loops as the variable “Beep”

After doing this you can just use encode(text)

If the text has a space the script will still work, but it would have a longer wait.

Then you want to wait for an input with the same text (i suggest lowering your text and the input’s text).

2 Likes

The only thing you’d need to do besides making the morse code sound play, which you already have the code for, is to make it so the door opens when you chat the decoded morse code message. Which is quite simple given that the Chatted event exists for Player instances. An example would be this

local plrs = game:GetService("Players")

local door = --Your door

local text = "Taco"

plrs.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		if msg ~= text or not door.CanCollide then return end
		door.CanCollide = false
		wait(5)
		door.CanCollide = true
	end)
end)

If you write Taco and the door isn’t open, it’ll open it for 5 seconds. The basis you need is just to use the Chatted event, you’d probably have to add more conditions to check if the player is able to open the door (so they can’t just open it when they’re at the beginning of the game for exampel)

2 Likes

Ah, thanks I know what to do now! :smiley:

2 Likes

Anytime! If you have anymore issues don’t be afraid to make another post!

2 Likes

I’m having an error, right know I’m just trying to make the morse code sound to play.
image
image

– I want the morse code sound to be random numbers
image

Did you forget to give it a text? What’s the full code?

1 Like

the text is going to be randomized

You didn’t give it anything to encode. If you want a random number to be encoded, just use math.random and tostring

while true do
	wait(1)
	Encode(tostring(math.random(10000,99999))
end

Gives a random number between 10000 and 99999 and turns it into a string and then encodes it

1 Like

It’s working now! Thank youuu!

1 Like

Anytime! If you have anymore issues once again don’t be afraid to make another psot!

1 Like

It’s all good now but I have a new problem. How would I stop it from changing numbers? I want it to pick a set of numbers and keep it until the player joins a new server and it changes.

image

Simple! Just put the tostring(math.random()) in a variable outside of the loop!

local num = tostring(math.random(10000,99999))

while true do
	wait(1)
	Encode(num)
end
1 Like

Thanks a lot your a life saver!

1 Like

Glad that I’ve helped you out haha! Hopefully if you have anymore issues I and others will be able to help!

1 Like

I took a break from all of that coding now I have another problem!!!

I don’t know how to check if a player chats the code in chat!!

I tried setting a Number Value and coping the code to it but it doesn’t work. :frowning:

Just check if it’s equal to num, no need for a NumberValue. Also, I’m not sure why you take the first 8 characters if it’s a five character code.

Edit: Actually the problem is that the while true do loop never ends, so the PlayerAdded event never gets connected to. Just put the event between where you define num and the loop is.

3 Likes

rhfgjgee That was simple. Thanks