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

Stuck on error "Expected 'end' (to close 'function' line 14), got 'elself'"?

Asked by 9 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 == 23783774 then
        productName = "$10,000+ Cash Boost"
        local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
        if cashmoney then
            cashmoney.Value = cashmoney.Value + 10000
        end
    elseif productId == 23783774 then
        productName = "$50,000+ Cash Boost"
        local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
        if cashmoney then
            cashmoney.Value = cashmoney.Value + 10000
        end
    elseif productId == 23783946 then
        productName = "+5 Walkspeed [STACKS]"
        local char = player.Character
        if char then
            local human = char:FindFirstChild("Humanoid")
            if human then
                human.WalkSpeed = human.WalkSpeed + 5
        end
    elseif productId == 24133649 then
        productName = "+25 Health Boost [STACKS]"
        local char = player.Character
        if char then
            local human = char:FindFirstChild("Humanoid")
            if human then
                human.MaxHealth = human.MaxHealth + 25
                human.Health = human.Health + 25
        end
    elseif productId == 23783812 then
        productName = "Gravity Coil [1 LIFE]"
        game.Lighting.GravityCoil:Clone().Parent = player.Backpack
        end
    elseif productId == 24133964 then
        productName = "Jetpack [1 LIFE]"
        game.Lighting.Jetpack:Clone().Parent = player.Backpack
        end
    elseif productId == 24139536 then
        productName = "Minigun [1 LIFE]"
        game.Lighting.Minigun:Clone().Parent = player.Backpack
       end
    elseif productId == 23918487 then
        productName = "NUKE [1 TIME USE]"
        game.Lighting.Nuke:Clone().Parent = game.Workspace
     end
    return Enum.ProductPurchaseDecision.PurchaseGranted
end

Please, help thanks!

1 answer

Log in to vote
3
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

This is why it's very important to tab your code correctly!

It's complaining about line 60. Look around line 60:

        productName = "Jetpack [1 LIFE]"
        game.Lighting.Jetpack:Clone().Parent = player.Backpack
        end
    elseif productId == 24139536 then
        productName = "Minigun [1 LIFE]"
        game.Lighting.Minigun:Clone().Parent = player.Backpack
       end
    elseif productId == 23918487 then
        productName = "NUKE [1 TIME USE]"

You have ends that are floating that don't match up with anything above them. Each elseifdoes NOT need its own end -- only the overall if needs an end.

Delete those unnecessary ends.


Next, you're missing an end:

        productName = "+5 Walkspeed [STACKS]"
        local char = player.Character
        if char then
            local human = char:FindFirstChild("Humanoid")
            if human then
                human.WalkSpeed = human.WalkSpeed + 5
        end

The second if in this place doesn't have a matchingend (scan down in the same column as it--the first one has an end there but the second doesn't)

The same problem happens a few more lines down.

0
Confused with its, -sorry- unmiss 337 — 9y
0
Thanks, for the help really appreciate it! ShadowShocks 42 — 9y
Ad

Answer this question