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

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

Asked by 8 years ago
Edited 8 years ago

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

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

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 ;)

1
With that it says "Expected 'end' (to close 'then' at line 7), got <eof>.. LuckyAura -1 — 8y
0
Look again pls, just add another end to close that one ;) LisaF854 93 — 8y
1
And "Expected 'end' (to close 'function' at line 3), got <eof>.. LuckyAura -1 — 8y
0
Then add another end ;) LisaF854 93 — 8y
0
Also this script is a mess, try indexing your script correctly please. LisaF854 93 — 8y
Ad
Log in to vote
0
Answered by
arshad145 392 Moderation Voter
7 years ago

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 .

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 gego120 2 — 4y

Answer this question