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

Disable script works but cant enable it after?

Asked by 6 years ago

So I made this script. When an admin says a word called ":disablebb" it should disable a script and also when an admin says ":enablebb" then it should enable the script. However, when i do :disablebb everything works it disables the script and everything. BUT when i do :enablebb it doesn't enable the script -script

local admins = {"WillBe_Stoped","imtoogud3322","Baller_Shard","kicksonhurri","conradvibes"
}
local prefix = ":"
local bbscript = script.Parent.BB

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(msg)
        for i,v in pairs (admins) do
            if bbscript.Disabled == false and v == player.Name and msg == prefix.."disablebb" then
                bbscript.Disabled = true
            elseif bbscript.Disabled == true and v == player.Name and msg == prefix.."enablebb" then
                bbscript.Disabled = false
            end
        end
    end)
end)

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago
local admins = {"PLAYER"}
local prefix = ":"
local bbscript = script.Parent.BB

function checkAdmin(player)
    for i,v in pairs (admins) do
        if player.Name == v then
            return true
        end
    end
end

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(msg)
        if msg == prefix.."disablebb" and checkAdmin(player) then
            if bbscript.Disabled == false then
                bbscript.Disabled = true
            end
        end
        if msg == prefix.."enablebb" and checkAdmin(player) then
            if bbscript.Disabled == true then
                bbscript.Disabled = false
            end
        end
    end)
end)
Ad

Answer this question