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

Restricted door gone wrong?

Asked by
nich17 95
10 years ago

I am currently working on making a restricted door where when a certain person says open the door will open. i wrote some script and it hasnt worked but i dont know why can anyone help?

game.Players.PlayerAdded:connect(function(player)
    if player.Name == "Player" then
        player.Chatted:connect(function(msg)
            if msg == "open" then
                Run()
            end
        end)
    end
end)

1 answer

Log in to vote
1
Answered by
ImageLabel 1541 Moderation Voter
10 years ago

Assuming Run an existing function, it should be working..

Run = function()
        print'ran'
    end
    game.Players.PlayerAdded:connect(function(player)
        if player.Name == "Player" then
            player.Chatted:connect(function(msg)
                if msg == "open" then
                    Run()
                end
            end)
        end
    end)
    

The sample above, for instance, would print "ran" if "Player" chats "open"

1
I actually put in some else statements to compliment the ifs and it worked so thanks for the help anyway nich17 95 — 10y
Ad

Answer this question