Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make the door open with one chat?

Asked by 8 years ago

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

1 answer

Log in to vote
0
Answered by 8 years ago

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.

0
Let's me test User#13091 0 — 8y
0
i have test 2 script but they doesnt work User#13091 0 — 8y
0
Is there any errors? I didn't test. SimplyRekt 413 — 8y
Ad

Answer this question