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

How to fix this Code GUI?

Asked by 8 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.

I do not know how to fix this GUI, whenever I enter a code in the script "Codes" it just shows "Submitting". It is not printing what it is supposed to be printing in output either.

local codes = require(game.ServerStorage.Codes)

local usedCodes = game:GetService("DataStoreService"):GetDataStore("UsedCodes")

local function IsInTable(t, thing)
    for i, v in pairs(t) do
        if v == thing then
            return(true)
        end
    end
    return(false)
end

game.Players.PlayerAdded:connect(function(player)
    if player.userId > 0 then
        local pCodes = usedCodes:GetAsync("user_" .. player.userId)
        if not pCodes then
            usedCodes:SetAsync("user_" .. player.userId, {})
        end
    end
end)

function game.ReplicatedStorage.RedeemCode.OnServerInvoke(player, code)
    if player.userId > 0 then
        code = string.lower(code)
        if codes[code] then
            local pCodes = usedCodes:GetAsync("user_" .. player.userId)
            if pCodes then
                if not IsInTable(pCodes, code) then
                    table.insert(pCodes, code)
                    usedCodes:SetAsync("user_" .. player.userId, pCodes)
                    codes[code](player)
                    return true, "Success!"
                else
                    return false, "You've already redeemed that code."
                end
            end
        else
            return false, "Invalid code."
        end
    end
    return false, "Sorry, guests can't redeem codes."
end

Script with Codes (ServerStorage):

local codes = {
    ["supercode"] = function(player)
        print(player.Name .. " entered a code!")
    end,
    ["examplecode"] = function(player)
        print("this example code was redeemed by " .. player.Name)
    end,
    ["mlg_swag_360"] = function(player)
        print(player.Name .. " is mlg!!!1!11!")
    end

    ["test"] = function(player)
        print("this example code was redeemed by " .. player.Name)
    end,
}

return(codes)
0
It is also not posting not printing the words it is supposed to be printing in Output. Percyjacksonpen15 5 — 8y
0
Can Anyone Help me? Percyjacksonpen15 5 — 8y

Answer this question