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

Whats wrong with the elseif in this script (look for where I say it is messed up)?

Asked by 8 years ago
game.StarterGui.ResetPlayerGuiOnSpawn = false

local MarketplaceService = game:GetService("MarketplaceService")

function getPlayerFromId(id)
    for i,v in pairs(game.Players:GetChildren()) do
        if v.userId == id then
            return v
        end
    end
    return nil
end

MarketplaceService.ProcessReceipt = function(receiptInfo)
    local productId = receiptInfo.ProductId
    local playerId = receiptInfo.PlayerId
    local player = getPlayerFromId(playerId)
    local productName 
    if productId == 34697576 then
        productName = "$10,000!"
        local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
        if cashmoney then
            cashmoney.Value = cashmoney.Value + 10000
        end
    elseif productId == 34698064 then
        productName = "$100,000!"
        local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
        if cashmoney then
            cashmoney.Value = cashmoney.Value + 100000
        end
    elseif productId == 34698110 then
        productName = "1,000,000!"
        local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
        game.ReplicatedStorage.MasterKey:FireClient(player,"PurchaseConfirm")
        if cashmoney then
            cashmoney.Value = cashmoney.Value + 1000000
        end
    elseif productId == 34698190 then
        productName = "+20 Walkspeed"
        local char = player.Character
        if char then
            local human = char:FindFirstChild("Humanoid")
            if human then
                human.WalkSpeed = human.WalkSpeed + 20
            end
        end
    elseif productId == 34698440  then
        productName = "Minigun"
        game.Lighting.Minigun:Clone().Parent=player.Backpack
            end
        end
    elseif productId == 34699873  then --THE ELSEIF IS UNDERLINED RED IN THE SCRIPT
        productName = "Jetpack"
        game.Lighting.Jetpack:Clone().Parent=player.Backpack
    end
    local message = Instance.new("Hint",workspace)
    message.Text = player.Name.." purchased "..productName.."!"
    coroutine.resume(coroutine.create(function()
        wait(2)
        message:destroy()
    end))

    return Enum.ProductPurchaseDecision.PurchaseGranted     
end
1
Above the error, it seems you have an extra end. Remove the extra end above the elseif, and you should be golden. User#11440 120 — 8y
0
Thank you so much, I fellso stupid -_- sentry3 6 — 8y

Answer this question