I've recently tried to make a script where it only runs when a certain player(s) say something in the chat. When the script runs the scripts Parent or the "door" will open. The script will have two functions so when the player(s) say "StoreOpen" it opens and when the players say "StoreClose" it closes.
what my trashy self came up with
door = script.Parent function onChatted(msg, recipient, speaker) local source = string.lower(speaker.Name) msg = string.lower(msg) if (msg == "open") then door.CanCollide = false door.Transparency = 0.7 wait(5) door.CanCollide = true door.Transparency = 0 end end function onPlayerEntered(newPlayer) newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) end game.Players.ChildAdded:connect(onPlayerEntered)
You would use the speaker to reference the player:
door = script.Parent function onChatted(msg, recipient, speaker) local source = string.lower(speaker.Name) msg = string.lower(msg) if speaker.Name == "Your Name here" then if (msg == "open") then door.CanCollide = false door.Transparency = 0.7 wait(5) door.CanCollide = true door.Transparency = 0 end end end function onPlayerEntered(newPlayer) newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) end game.Players.ChildAdded:connect(onPlayerEntered)