0
votes

So i'm coding my DFrame for an addon im working on and I keep getting this error.

"[ERROR] addons/dareaddon/lua/autorun/sh.lua:25: 'end' expected (to close 'if' at line 5) near ''"

Here is my original code.

if (CLIENT) then
    local midW, midH = ScrW() / 2, Scrh() / 2
    local function OpenMyDerma()
        local MyDerma = vgui.Create( "DFrame" )
        MyDerma:SetSize( 250, 250 )
        MyDerma:SetPos( midW - ( MyDerma:GetWide() / 2 ), midH - ( MyDerma:GetTall() / 2) )
        MyDerma:SetTitle( "OriginalServers Jailbreak" )

        local MyLabel = vgui.Create( "DLabel", MyDerma )
        MyLabel:SetPos( 90, 30 )
        MyLabel:SetText( "LabelTest" )

        local MyButton = vgui.Create( "DButton", MyDerma )
        MyButton:SetText( "Click to die." )
        MyButton:SetPos( 90, 60 )
        MyButton.DoClick = function()
            RunConsoleCommand( "explode" )
        end
    end
    concommand.Add( "openderma", OpenMyDerma )
end

this code is kind of hard to understand with the indents so here is a screenshot. Code Screenshot

any help is greatly appreciated.

1
Probably, your system requires a newline after the last line when reading the script from file? - Egor Skriptunoff
ScrH() or Scrh() ? - Egor Skriptunoff
Is this the entire script? Error indicates that there is an 'if' on line 5 which I do not see. - MattJeanes

1 Answers

0
votes

[ERROR] addons/dareaddon/lua/autorun/sh.lua:25: 'end' expected (to close 'if' at line 5) near

Read the error exactly. Find the folder

addons/dareaddon/lua/autorun/

Then

  1. Open the file called sh.lua.
  2. Go to line "25" and check.
  3. Go to the function that is around line 25
  4. Check if the function is closed
  5. If not then go at line "5" look through the code and close if with end. Make sure that there isn't any other if statement under line 5, if yes then you have something like this.
if x
   if y
   end
end

or many make it

if x
end
if y
end

depending on whether you want to test y only if x or you want to test x and y independently.

You need to close if with end

like

FUNCTION
    IF


    END;
END;