This is what I've made so far:
script.Parent.Transparency = 1 script.Parent.CanCollide = true -- if player says !open with rank 12+ Group ID: 5370359 script.Parent.Transparency = 0 script.Parent.CanCollide = false
I just need to know what the code is for "if player says !open with rank 12+ Group ID: 5370359".
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 --find the door and change what you need end end end) end)
That's all there is to it. Hope I helped!