Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Infinite 'End' glitch. Expected ')' got 'end' ?

Hey, I've tried adding 'end to fix it, I've also tried to put () but nothing seems to work. Any tips?

The last 'end' is errored with this: https://imgur.com/a/iqCZvTV

local productId1 = 976013381 -- 15
local productId2 = 976013480   -- 50
local productId3 = 976016228	-- 150
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
if game.Players.LocalPlayer.leaderstats.Stage.Value == 111 then -- change number to stage
    game:GetService("MarketplaceService"):PromptProductPurchase(player, productId3) -- make Id2 the id of the diff cost
else
if game.Players.LocalPlayer.leaderstats.Stage.Value >= 51 then -- change the number to the stage
    game:GetService("MarketplaceService"):PromptProductPurchase(player, productId2)
else
if game.Players.LocalPlayer.leaderstats.Stage.Value <= 49 then -- change the number to the stage
    game:GetService("MarketplaceService"):PromptProductPurchase(player, productId1)
end
end
end
end)


script.Parent.MouseButton1Click:Connect(function()

if game.Players.LocalPlayer.leaderstats.Stage.Value == 10 then -- change number to stage
    game:GetService("MarketplaceService"):PromptProductPurchase(player, productId2) -- make Id2 the id of the diff cost
else
if game.Players.LocalPlayer.leaderstats.Stage.Value == 20 then -- change number to stage
    game:GetService("MarketplaceService"):PromptProductPurchase(player, productId2) -- make Id2 the id of the diff cost
else
if game.Players.LocalPlayer.leaderstats.Stage.Value == 30 then -- change number to stage
    game:GetService("MarketplaceService"):PromptProductPurchase(player, productId2) -- make Id2 the id of the diff cost
else
if game.Players.LocalPlayer.leaderstats.Stage.Value == 40 then -- change number to stage
    game:GetService("MarketplaceService"):PromptProductPurchase(player, productId2) -- make Id2 the id of the diff cost
else
if game.Players.LocalPlayer.leaderstats.Stage.Value == 50 then -- change the number to the stage
    game:GetService("MarketplaceService"):PromptProductPurchase(player, productId2)
else
if game.Players.LocalPlayer.leaderstats.Stage.Value == 60 then -- change the number to the stage
    game:GetService("MarketplaceService"):PromptProductPurchase(player, productId3)
else
if game.Players.LocalPlayer.leaderstats.Stage.Value == 70 then -- change the number to the stage
    game:GetService("MarketplaceService"):PromptProductPurchase(player, productId3)
else
if game.Players.LocalPlayer.leaderstats.Stage.Value == 80 then -- change the number to the stage
    game:GetService("MarketplaceService"):PromptProductPurchase(player, productId3)
else
if game.Players.LocalPlayer.leaderstats.Stage.Value == 90 then -- change the number to the stage
    game:GetService("MarketplaceService"):PromptProductPurchase(player, productId3)
else
if game.Players.LocalPlayer.leaderstats.Stage.Value == 100 then -- change the number to the stage
    game:GetService("MarketplaceService"):PromptProductPurchase(player, productId3)
else
if game.Players.LocalPlayer.leaderstats.Stage.Value == 110 then -- change the number to the stage
    game:GetService("MarketplaceService"):PromptProductPurchase(player, productId3)

end
end
end
end
end
end
end
end
end
end
end
end
end


3 comments

0

Please indent your code properly so it's easier for us to read and therefore figure out your problem.

0

First off why do you got so many "end"

0

Well first of all, this is horribly formatted. You can make this much easier with math and functions that take about 30 lines max.

1 answer

First of all, indent your code, second of all, use elseif instead of else and then if like this:

elseif game.Players.LocalPlayer.leaderstats.Stage.Value == 110 then

and third of all, you didn't put the bracket to close the mousebutton1click, change the last end at line 68 to:

end)

This discussion is preserved as it was. New answers, comments, and votes are closed.