Search code examples
luarobloxexploitluau

How to fix syntax Roblox Lua


I kept getting error, but its seems already good at if and elseif statements, kept giving me last line error

How the code works? When chat :example it does do ..., You can check under below, also this code for exploit in game, help me to fix some error syntax

Code :

local players = game:GetService("Players")

local localPlayer = players.LocalPlayer
localPlayer.Chatted:connect(function(cht)
    if cht:match(":kill all") then
        for _, player in pairs(players:GetPlayers()) do
            if player ~= localPlayer then
                game.Players:Chat(":explode "..player.Name.."")
                print("Successfully Killed " .. player.Name .. ".")
            end
        end
    elseif cht:match(":explode all") then
        for _, player in pairs(players:GetPlayers()) do
            if player ~= localPlayer then
                game.Players:Chat(":explode "..player.Name.."")
                print("Successfully Exploded " .. player.Name .. ".")
            end
        end
    elseif cht:match(":freeze all") then
        for _, player in pairs(players:GetPlayers()) do
            if player ~= localPlayer then
                game.Players:Chat(":freeze "..player.Name.."")
                print("Successfully Froze " .. player.Name .. ".")
            end
        end
    elseif cht:match(":jail all") then
        for _, player in pairs(players:GetPlayers()) do
            if player ~= localPlayer then
                game.Players:Chat(":jail "..player.Name.."")
                print("Successfully Jailed " .. player.Name .. ".")
            end
        end
    elseif cht:match(":floppa all") then
        for _, player in pairs(players:GetPlayers()) do
            if player ~= localPlayer then
                game.Players:Chat(":floppa "..player.Name.."")
                print("Successfully Killed " .. player.Name .. ".")
            end
        end
    elseif cht:match(":wednesday all") then
        for _, player in pairs(players:GetPlayers()) do
            if player ~= localPlayer then
                game.Players:Chat(":wednesday "..player.Name.."")
                print("Successfully Transformed " .. player.Name .. " Into Wednesday.")
            end
        end
    elseif cht:match(":void all") then
        for _, player in pairs(players:GetPlayers()) do
            if player ~= localPlayer then
                game.Players:Chat(":void "..player.Name.."")
                print("Successfully Transformed " .. player.Name .. " Into Void.")
            end
        end
    elseif cht:match(":ff all") or cht:match(":forcefield all") then
        for _, player in pairs(players:GetPlayers()) do
            if player ~= localPlayer then
                game.Players:Chat(":ff "..player.Name.."")
                print("Successfully Forcefielded " .. player.Name .. ".")
            end
        end
    elseif cht:match(":god all") then
        for _, player in pairs(players:GetPlayers()) do
            if player ~= localPlayer then
                game.Players:Chat(":god "..player.Name.."")
                print("Successfully Made god mode to "..player.Name.."")
                    elseif cht:match(":unff all") then
        for _, player in pairs(players:GetPlayers()) do
            if player ~= localPlayer then
                game.Players:Chat(":unff "..player.Name.."")
                print("Successfully Disabled Forcefield " .. player.Name .. ".")
            end
        end
    elseif cht:match(":unjail all") then
        for _, player in pairs(players:GetPlayers()) do
            game.Players:Chat(":unjail all "..player.Name.."")
            print("Successfully Unjailed " .. player.Name .. ".")
            wait(0.2)
        end
    elseif cht:match(":ungod all") then
        for _, player in pairs(players:GetPlayers()) do
            if player ~= localPlayer then
                game.Players:Chat(":ungod "..player.Name.."")
                print("Successfully Disabled God Mode " .. player.Name .. ".")
            end
        end
    elseif cht:match(":disco all") then
        for _, player in pairs(players:GetPlayers()) do
            if player ~= localPlayer then
                game.Players:Chat(":disco "..player.Name.."")
                print("Successfully Set Disco Mode for " .. player.Name .. ".")
            end
        end
    end
end
end
)

I keep trying to fix it by console in Roblox /console, really following what it's do, and yeah, struggling


Solution

  • Try this :

    
    local players = game:GetService("Players")
    
    local localPlayer = players.LocalPlayer
    localPlayer.Chatted:connect(function(cht)
        if cht:match(":kill all") then
            for _, player in pairs(players:GetPlayers()) do
                if player ~= localPlayer then
                    game.Players:Chat(":explode "..player.Name.."")
                    print("Successfully Killed " .. player.Name .. ".")
                end
            end
        elseif cht:match(":explode all") then
            for _, player in pairs(players:GetPlayers()) do
                if player ~= localPlayer then
                    game.Players:Chat(":explode "..player.Name.."")
                    print("Successfully Exploded " .. player.Name .. ".")
                end
            end
        elseif cht:match(":freeze all") then
            for _, player in pairs(players:GetPlayers()) do
                if player ~= localPlayer then
                    game.Players:Chat(":freeze "..player.Name.."")
                    print("Successfully Froze " .. player.Name .. ".")
                end
            end
        elseif cht:match(":jail all") then
            for _, player in pairs(players:GetPlayers()) do
                if player ~= localPlayer then
                    game.Players:Chat(":jail "..player.Name.."")
                    print("Successfully Jailed " .. player.Name .. ".")
                end
            end
        elseif cht:match(":floppa all") then
            for _, player in pairs(players:GetPlayers()) do
                if player ~= localPlayer then
                    game.Players:Chat(":floppa "..player.Name.."")
                    print("Successfully Killed " .. player.Name .. ".")
                end
            end
        elseif cht:match(":wednesday all") then
            for _, player in pairs(players:GetPlayers()) do
                if player ~= localPlayer then
                    game.Players:Chat(":wednesday "..player.Name.."")
                    print("Successfully Transformed " .. player.Name .. " Into Wednesday.")
                end
            end
        elseif cht:match(":void all") then
            for _, player in pairs(players:GetPlayers()) do
                if player ~= localPlayer then
                    game.Players:Chat(":void "..player.Name.."")
                    print("Successfully Transformed " .. player.Name .. " Into Void.")
                end
            end
        elseif cht:match(":ff all") or cht:match(":forcefield all") then
            for _, player in pairs(players:GetPlayers()) do
                if player ~= localPlayer then
                    game.Players:Chat(":ff "..player.Name.."")
                    print("Successfully Forcefielded " .. player.Name .. ".")
                end
            end
        elseif cht:match(":god all") then
            for _, player in pairs(players:GetPlayers()) do
                if player ~= localPlayer then
                    game.Players:Chat(":god "..player.Name.."")
                    print("Successfully Made god mode to "..player.Name.."")
                elseif cht:match(":unff all") then
                    for _, player in pairs(players:GetPlayers()) do
                        if player ~= localPlayer then 
                         game.Players:Chat(":unff "..player.Name.."")
                            print("Successfully Disabled Forcefield " .. player.Name .. ".")
                        end
                    end
                end
        elseif cht:match(":unjail all") then
            for _, player in pairs(players:GetPlayers()) do
                game.Players:Chat(":unjail all "..player.Name.."")
                print("Successfully Unjailed " .. player.Name .. ".")
                wait(0.2)
            end
        elseif cht:match(":ungod all") then
            for _, player in pairs(players:GetPlayers()) do
                if player ~= localPlayer then
                    game.Players:Chat(":ungod "..player.Name.."")
                    print("Successfully Disabled God Mode " .. player.Name .. ".")
                end
            end
        elseif cht:match(":disco all") then
            for _, player in pairs(players:GetPlayers()) do
                if player ~= localPlayer then
                    game.Players:Chat(":disco "..player.Name.."")
                    print("Successfully Set Disco Mode for " .. player.Name .. ".")
                end
            end
        end
    end)
    
    

    U haded some messed up end statements at ur code.

    This shoulder probably work now.