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

Expected 'end' (to close 'then' at line 16), got <eof>?

Where would the ends go to make the error go away? Won't extra ends break the script?

	for i,c in pairs(script.Parent:GetChildren()) do
		if c:IsA("ImageButton") then
			c.MouseButton1Click:connect(function()
				local p = script.Parent.Parent.Parent.Parent.Parent
				local GPS = game:GetService("MarketplaceService")
				
	if GPS:PlayerOwnsAsset(p, script.Parent.Rex.Value) or GPS:PlayerOwnsAsset(p, script.Parent.Sat.Value) or GPS:PlayerOwnsAsset(p, script.Parent.Fusion.Value) then
	for _,v in pairs(game.ReplicatedStorage.Game_Tools[suit.Tools.Value]:GetChildren()) do
		if v:IsA("HopperBin") or v:IsA("Tool") then
			if p:FindFirstChild'Backpack' then
				v:clone().Parent = p.Backpack
			end
		end
	end

	if GPS:PlayerOwnsAsset(p, script.Parent.Rex.Value) and GPS:PlayerOwnsAsset(p, script.Parent.Sat.Value) then
		for _,v in pairs(game.ReplicatedStorage.Game_Tools[suit.Tools.Value]:GetChildren()) do
			if v:IsA("HopperBin") or v:IsA("Tool") then
				if p:FindFirstChild'Backpack' then
					v:clone().Parent = p.Backpack
				end 
			end 
		end <-- error from here

2 answers

No, notice how you opened an if statement, then an i,v in pairs, then an if, then an if, you need 4 ends to close all of them so you should do this:

for i,c in pairs(script.Parent:GetChildren()) do
    if c:IsA("ImageButton") then
        c.MouseButton1Click:connect(function()
            local p = script.Parent.Parent.Parent.Parent.Parent
            local GPS = game:GetService("MarketplaceService")

if GPS:PlayerOwnsAsset(p, script.Parent.Rex.Value) or GPS:PlayerOwnsAsset(p, script.Parent.Sat.Value) or GPS:PlayerOwnsAsset(p, script.Parent.Fusion.Value) then
for _,v in pairs(game.ReplicatedStorage.Game_Tools[suit.Tools.Value]:GetChildren()) do
    if v:IsA("HopperBin") or v:IsA("Tool") then
        if p:FindFirstChild'Backpack' then
            v:clone().Parent = p.Backpack
        end
    end
end

if GPS:PlayerOwnsAsset(p, script.Parent.Rex.Value) and GPS:PlayerOwnsAsset(p, script.Parent.Sat.Value) then
    for _,v in pairs(game.ReplicatedStorage.Game_Tools[suit.Tools.Value]:GetChildren()) do
        if v:IsA("HopperBin") or v:IsA("Tool") then
            if p:FindFirstChild'Backpack' then
                v:clone().Parent = p.Backpack
            end 
        end 
    end 
end
end --This is to close the if statement you opened on line 26.

hope It helped ;)

5 comments

1

With that it says "Expected 'end' (to close 'then' at line 7), got ..

0

Look again pls, just add another end to close that one ;)

1

And "Expected 'end' (to close 'function' at line 3), got ..

0

Then add another end ;)

0

Also this script is a mess, try indexing your script correctly please.

Messy scripts are unefficient for the scripter himself.

for i,c in pairs(script.Parent:GetChildren()) do
	if c:IsA("ImageButton") then
		c.MouseButton1Click:connect(function()
		local p = script.Parent.Parent.Parent.Parent.Parent
        	local GPS = game:GetService("MarketplaceService")
		if GPS:PlayerOwnsAsset(p, script.Parent.Rex.Value) or 
			GPS:PlayerOwnsAsset(p, script.Parent.Sat.Value) or GPS:PlayerOwnsAsset(p,script.Parent.Fusion.Value) then
               end
	end
end

for _,v in pairs(game.ReplicatedStorage.Game_Tools[suit.Tools.Value]:GetChildren()) do
    if v:IsA("HopperBin") or v:IsA("Tool") then
        if p:FindFirstChild'Backpack' then
            v:clone().Parent = p.Backpack
        end
    end
end

if GPS:PlayerOwnsAsset(p, script.Parent.Rex.Value) and GPS:PlayerOwnsAsset(p, 	script.Parent.Sat.Value) then
end

for _,v in pairs(game.ReplicatedStorage.Game_Tools[suit.Tools.Value]:GetChildren()) do
        if v:IsA("HopperBin") or v:IsA("Tool") then
            if p:FindFirstChild'Backpack' then
                v:clone().Parent = p.Backpack
            end 
        end 
end <-- error from here

Should work now. Post results , if it does not .

1 comment

0

I had the same exact problem, it works fine now thanks. I had to add more ends because my script was pretty big. Thank you again! :D

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