So, I am working on a tycoon game and I was working on my Dev Product Shop and I got this annoying error when editing the code. Any ideas on how to fix this?
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
Expected 'end' (to close 'function' line 14), got 'elself' is the error Thanks for looking!

1 comment
I am probably wrong, as I am not a very good scripter, but I don't believe you end every single elseif, try just having the one end, and then the second end, after return"