Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make !open and !close work infinitely?

Asked by 4 years ago
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
                workspace.Door.Transparency = 1
                workspace.Door.CanCollide = false
            end
        end
    end)
end) 

game.Players.PlayerAdded:Connect(function(plr)
    plr.Chatted:Connect(function(msg)
            if msg:sub(1, 5) == "!close" or msg:sub(1, 5) == "!Close" then
            if plr:GetRankInGroup(5370359) >= 12 then
                workspace.Door.Transparency = 1
                workspace.Door.CanCollide = false
            end
        end
    end)
end) 

How do I make it so !open and !close can be used infinitely?

0
Try using if then statements to check if the door is open or closed and use debounce for cooldowns. Just a guess. killerbrenden 1537 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago
if msg:sub(1, 5) == "!close" or msg:sub(1, 5) == "!Close" then

The word, !close and !Close have 6 characters, not 5. That's your error and that's why it won't close on line 14.

0
Thank you! I did not notice that! Sloth_WasTaken 41 — 4y
0
No problem! Just make sure you always double check your code. killerbrenden 1537 — 4y
Ad

Answer this question