Alright, so I'm trying to make a script that opens/closes a door depending on what the person says, and what rank in my group they are. Although I've tried to fix it, I just can't. Here's my code:
local staffRankId = 12
local groupId = 5947903
game:GetService("Players").PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
if plr:GetRankInGroup(groupId) >= staffRankId then
if msg =="/spawn" then
game.Workspace.Spawn.CanCollide = false
end
if msg =="/cspawn" then
game.Workspace.Spawn.CanCollide = true
end
end
end)
Thanks in advance.

2 comments
This isn't the answer, but it's a tip. After "plr.Chatted:Connect(function(msg)" put "msg = string.lower(msg)" This makes sure that even though the player says the command with incorrect capitalization, the command will still execute (just make sure all the letters in the "if msg == """ are lowercase). An alternative but less efficient way is by doing: "if string.lower(msg) == "/spawn" then".
And do that for every single one.