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

How to make the door open with one chat?

So I want to make a door will open with the chat is -opendoor

1 answer

You need to use the Chatted function. When you call the function, you will listen for the message, "-opendoor".

You will also need to use string.sub, and string.lower.

local player=game.Players.LocalPlayer --getting the player
local door=workspace.Door --this is where the door is

player.Chatted:connect(function(msg) --when the player chats something, listen.
	if string.sub(string.lower(msg),1,9)==string.lower("-opendoor") then --if they chat "-opendoor" then.. using string.lower is better because it isn't case sensitive.
		door.Transparency=.8 --Makes the door semi-transparent
		door.CanCollide=false --You can walk through
		wait(2) --after 2 seconds
		door.Transparency=1 --Makes the door opaque
		door.CanCollide=true --You can not walk through
	end
end)

Only allowing certain players to say "-opendoor"

local player=game.Players.LocalPlayer --getting the player
local door=workspace.Door --this is where the door is
--v add people you want to be able to say "-opendoor"
local allowed={
	["Megadude1536"]=true;
	["SimplyRekt"]=true;
	["Friend"]=true;
}

player.Chatted:connect(function(msg) --when the player chats something, listen.
	for i,v in pairs(allowed) do
		if v.Name==player.Name then --if their name is in the allowed list then
			if string.sub(string.lower(msg),1,9)==string.lower("-opendoor") then --if they chat "-opendoor" then.. using string.lower is better because it isn't case sensitive.
				door.Transparency=.8 --Makes the door semi-transparent
				door.CanCollide=false --You can walk through
				wait(2) --after 2 seconds
				door.Transparency=1 --Makes the door opaque
				door.CanCollide=true --You can not walk through
			end
		end
	end
end)

PLEASE NOTE

This is NOT a request site. You should always provide scripts that you've tried and methods you tried but haven't worked. You should also tell us more in depth what you want, otherwise we won't know what you want in the script.

3 comments

0

Let's me test

0

i have test 2 script but they doesnt work

0

Is there any errors? I didn't test.

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