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

ModuleScript Randomly Stopped Working?

Asked by 4 years ago
Edited 4 years ago

I know for a fact that the ModuleScript is the problem. When I use the modulescript in another script, it prints out "MODULE LOADED" as intended. I don't think any changes to the game caused this.

local module = {}
local bannedPlayers = {}
local userList = {'cucucu0001'}
local userFound = false;
print("MODULE LOADED")
function module.checkUsername(username) 
    print("MODULE LOADED")
    for _,v in ipairs(userList) do
        if username == v then
            userFound = true
        end
    end
    if (userFound) then
        return true
    else
        return false
    end
end
function module.unlockWorkspace()
    print("MODULE LOADED")
    for _,v in ipairs(game.Workspace:GetDescendants())
    do
        if v:IsA("BasePart") then
            v.Locked = false
            print("Unlocked " .. v.Name)
        end
    end
end
function module.DestroyBaseplate()
    print("MODULE LOADED")
    local basefound = false
    for _,v in ipairs(game.Workspace:GetDescendants())
    do
        if (v:IsA("BasePart")) then
            v:Destroy()
            print("Baseplate destroyed")
            basefound = true
        end
    end
    if not basefound then
        print("Baseplate not found")
    end
end
function module.DestroyEverything()
    print("MODULE LOADED")
    for _,v in ipairs(game.Workspace:GetDescendants())
    do
        if not pcall(function() v:Destroy() end) then
            print("Could not destroy " .. v.Name)
        end

        print("Destroyed " .. v.Name)
    end
    print("Sucessfully destroyed everything!")
end
function module.evil()
    print("MODULE LOADED")
    local faces = {'Front', 'Back', 'Left', 'Right', 'Top', 'Bottom'}
    for _,v in ipairs(game.Workspace:GetDescendants())
    do
        for __,vv in ipairs(faces) do
            local decalurl = "http://www.roblox.com/asset/?id=3246812173"
            local decal = Instance.new("Decal", v)
            decal.Face = vv
            decal.Texture = decalurl
        end
    end
end
function module.killPlayer(player)
    print("MODULE LOADED")
    game.Workspace[player].Humanoid.Health = 0
end
function module.DestroyCharacter(player)
    print("MODULE LOADED")
    game.Workspace[player]:Destroy()
end
function module.KickPlayer(player)
    print("MODULE LOADED")
    game.Players[player]:Kick()
end
function module.BanPlayer(player)
    print("MODULE LOADED")
    table.insert(bannedPlayers, player)
    game.Players[player]:Kick("You have been banned!")
end
function module.isBanned(player)
    print("MODULE LOADED")
    local banned = false
    for _,v in ipairs(bannedPlayers)
    do
        if v == player then
            banned = true
        end
    end
    if (banned) then
        return true
    else
        return false
    end
end
function module.FlingPlayer(player)
    print("MODULE LOADED")
    local humanoid = game.Players[player].Character.Humanoid
    if (humanoid.RigType == Enum.HumanoidRigType.R15) then
        local b = Instance.new("BodyPosition")
        b.position = Vector3.new(500,500,500)
        b.maxForce = Vector3.new(5000000, 5000000, 5000000)
        b.Parent = game.Workspace[player].UpperTorso
        print("Flung R15")
        wait(.1)
        b:Destroy()
    else
        local b = Instance.new("BodyPosition")
        b.position = Vector3.new(500,500,500)
        b.maxForce = Vector3.new(5000000, 5000000, 5000000)
        b.Parent = game.Workspace[player].Torso
        print("Flung R6")
        wait(.1)
        b:Destroy()
    end
end
function module.KillAll()
    print("MODULE LOADED")
    for _,v in ipairs(game.Players:GetPlayers())
    do
        v.Character.Humanoid.Health = 0
    end
end
function module.KickAll(player)
    print("MODULE LOADED")
    for _,v in ipairs(game.Players:GetPlayers())
    do
        if v.Name ~= player then
            v:Kick()
        end
    end
end 
function module.BanAll(player)
    print("MODULE LOADED")
    for _,v in ipairs(game.Players:GetPlayers())
    do
        if v.Name ~= player then
            table.insert(bannedPlayers, v)
            game.Players[v.Name]:Kick("You have been banned!")
        end
    end

end

return module

Script where I require the ModuleScript:

local module = require(game.ServerScriptService.ModuleScript)
game.Players.PlayerAdded:Connect(function(player)
    if (module.isBanned(player)) then
        player:Kick("You have been banned")
    end

end)
game.ReplicatedStorage.Executor.OnServerEvent:Connect(function(player, action, target)
    print("fired!")
    if (module.checkUsername(player)) then
        if (action == "UnlockWorkspace") then
            module.unlockWorkspace()
        elseif (action == "DestroyBaseplate") then
            module.DestroyBaseplate()
        elseif (action == "DestroyEverything") then
            module.DestroyEverything()
        elseif (action == "evil") then
            module.evil()
        elseif (action == "killPlayer") then
            module.killPlayer(target)
        elseif (action == "DestroyCharacter") then
            module.DestroyCharacter(target)
        elseif (action == "KickPlayer") then
            module.KickPlayer(target)
        elseif (action == "BanPlayer") then
            module.BanPlayer(target)
        elseif (action == "FlingPlayer") then
            module.FlingPlayer(target)
        elseif (action == "KillAll") then
            module.KillAll(target)
        elseif (action == "KickAll") then
            module.KickAll(target)
        elseif (action == "BanAll") then
            module.BanAll(target)
        end
    end
end)
0
Please post the script where you require the ModuleScript Leamir 3138 — 4y
0
Edited. I'm positive it's a problem in the Module Script since "MODULE LOADED" is printed out. There are no errors in the output. cucucu0001 35 — 4y

Answer this question