Ranking door help

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
    so only ranks 250+ can use !open and !close to open door
  2. What is the issue?
    idk how to make those
function LookRank(player)
    local Groups = game:GetService("GroupService"):GetGroupsAsync(player.UserId)
    for i=1, #Groups do
        if Groups[i].Name == "group name" then
            return Groups[i].Rank
        end
    end
    return 0
end

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg)
		if LookRank(player) >= 250 then
			if (msg:lower) == "!open") then
				script.Parent.CanCollide = false
				wait(1)
				elseif (msg:lower == "!close") then
					script.Parent.CanCollide = true
			end
		end
end)

anyone has ideas where are my mistakes?

1 Like

Here’s how I would recreate that script

local GroupID = 0

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg)
		if player:GetRankInGroup(GroupID) >= 250 then
			if (msg:lower) == "!open" then
				script.Parent.CanCollide = false
				wait(1)
			elseif (msg:lower == "!close") then
				script.Parent.CanCollide = true
			end
		end
    end)
end)
4 Likes

Uhm, I got an error at line 6…

One bracket is missing, just add one

1 Like

Ah, I see thank you lol. (30 chars)

whats the wait(1) under the first msg conditional for?

To prevent users to spam that…?

But the function still fires every time a player chats. And spamming wouldn’t cause any behavior changes.

When a player with credentials says ‘!open’, it stays that way until another player with credentials says ‘!close’.

Eh, idk I will just remove it, I meant it would prevent spam, but nevermind

Cool, doesn’t make a difference either way. Wasn’t sure if you wanted the door to auto close after a second. But sounds like it works how you want it to.