• GMOD > '<eof>' expected near 'elseif' Lua Help?
    2 replies, posted
Just to start of I am extremely new to coding in lua! Please don't hate me <3 . Anyways, I am getting the error: [ERROR] lua/weapons/brickv2.lua:10: '<eof>' expected near 'elseif' In this code: if SERVER then -- Serverside Code -- AddCSLuaFile ("shared.lua") SWEP.Weight = 5 SWEP.AutoSwitchTo = false SWEP.AutoSwitchFrom = false end elseif CLIENT then -- Clientside Code -- SWEP.PrintName = "Brick V2" SWEP.Slot = 4 SWEP.SlotPos = 1 SWEP.DrawAmmo = false SWEP.DrawCrosshair = false undo.Create("Brick_V2_Entity") language.Add("Undone_Brick_V2_Entity","Undone Thrown Brick") end SWEP.Author = "ItzKaneki" SWEP.Contact = "steamcommunity.com/id/itzkaneki69" SWEP.Purpose = "Smack 'em with a brick!" SWEP.Instructions = "Just smack 'em!" SWEP.Category = "Other" SWEP.Spawnable = true SWEP.AdminSpawnable = true SWEP.ViewModel = "models/props_junk/CinderBlock01a.mdl" SWEP.WorldModel = "models/weapons/c_brick.mdl" local ShootSound = Sound("Weapon_Crowbar.Melee_Hit") function SWEP:Reload() end function SWEP:Think() end function SWEP:throw_attack (model_file) if (!SERVER) then return end local ent = ents.Create("prop_physics") ent:SetModel(models/props_junk/CinderBlock01a.mdl) ent:SetPos(self.Owner:EyePos() + (self.Owner:GetAimVector() * 16)) ent:SetAngles(self.Owner:EyeAngles()) ent:Spawn() local phys = ent:GetPhysicsObject() if !(phys && IsValid(phys)) then ent:Remove() return end phys:ApplyForceCenter(self.Owner:GetAimVector():GetNormalized() * math.pow(tr.HitPos:Length(), 3)) cleanup.Add(self.Owner, "props", ent) undo.Create ("Thrown_SWEP_Entity") undo.AddEntity (ent) undo.SetPlayer (self.Owner) undo.Finish() end function SWEP:PrimaryAttack() Self:throw_attack("models/props_junk/CinderBlock01a.mdl") end function SWEP:SecondaryAttack() end I did some research and found that <eof> means end of function but I don't understand what I need to do to fix it. It is probably really easy but as I said I'm new (my excuse :P) Any help please? [highlight](User was banned for this post ("Missed forum description - see Developer Discussion for help!" - NiandraLades))[/highlight]
Take the end out after if SERVER then.
After I do that I got this error: [ERROR] lua/weapons/brickv2.lua:21: attempt to call field 'Create' (a nil value) Any help with this one? --EDIT-- I fixed this, I had it so it would try to create an undo when it wasn't needed or whatever. I saw undo code down further and figured out I'm dumb
Sorry, you need to Log In to post a reply to this thread.