Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to get a door that opens with one word?

I'm planning to make an office area with a unique door that opens when you say something, but I don't know how I can do that. May someone help me with this?

2 answers

The Player.Chatted event has the message argument that gets passed to a function to interpret what a player says as a string literal.

game.Players.PlayerAdded:connect(function(player)
	player.Chatted:connect(function(msg)
		if msg=="something"then
			OpenDoor()
		end
	end)
end)

2 comments

0

Do you do something with the OpenDoor()?

0

OpenDoor is your function that does whatever it is with whatever way you want to open whatever door it is you have.

First, you define the path of the brick, using a variable is the best.

local brick = (BRICK PATH HERE) -- Change (BRICK PATH HERE) to where the brick is.

Then, you listen to event chatted, but first you need to define the player also.

local brick = (BRICK PATH HERE)
game.Players.PlayerAdded:connect(function(player) -- Defining player/Listening to join to get player.
	player.Chatted:connect(function(msg) -- Listening to their chat. Variable "msg" is the player's chat.
	end)
end)

Then finally, read the message and make changes to the brick so they can move.

local brick = (BRICK PATH HERE)
game.Players.PlayerAdded:connect(function(player)
	player.Chatted:connect(function(msg)
		if msg == "string" then -- If the message is "string" then do...
			brick.CanCollide = false -- Allow player to move through block.
			wait(3) -- Wait 3 seconds...
			brick.CanCollide = true -- Disallow player to move through block.
		end
	end)
end)

If you want, you can add privileges.

local Privileged = {"Deltrac", "randomguy"} -- In Privileged, there is Deltrac and Randomguy.
local brick = (BRICK PATH HERE)
game.Players.PlayerAdded:connect(function(player)
	player.Chatted:connect(function(msg)
		if player.Name == Privileged then -- If player's name is in table Privileged
			if msg == "string" then
				brick.CanCollide = false
				wait(3)
				brick.CanCollide = true
			end
		end
	end)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.