✓ Accepted answer
In order to open a door when the player says "!open", we first need a way to figure out when the player is chatting. To do this, we are going to connect the chatted event every time a player joins. This would look like so:
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
end)
end)
Ok, now we know that the player chatted, but we don't know what they said. Luckily, the event gives us the message (I made the variable msg but you can change this to whatever you want). Now we just need to check if the first 5 letters of their message says "!open". To do this we can use :sub. Doing so would look like this:
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
if msg:sub(1, 5) == "!open" or msg:sub(1, 5) == "!Open" then
end
end)
end)
Now we are checking if the player is trying to open the door. The final step is to check if their role is 12 or higher. We can do this with :GetRankInGroup, making the final product look like this:
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
if msg:sub(1, 5) == "!open" or msg:sub(1, 5) == "!Open" then
if plr:GetRankInGroup(5370359) >= 12 then
end
end
end)
end)
That's all there is to it. Hope I helped!
3 comments
GetRankInGroup https://developer.roblox.com/en-us/api-reference/function/Player/GetRankInGroup
^ thank you for spotting that.
Thank you for your help!