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

How to get a door that opens with one word?

Asked by 10 years ago

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

Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
10 years ago

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)
0
Do you do something with the OpenDoor()? Deltrac 0 — 10y
0
OpenDoor is your function that does whatever it is with whatever way you want to open whatever door it is you have. 1waffle1 2908 — 10y
Ad
Log in to vote
0
Answered by
Bloxks 30
10 years ago

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)

Answer this question