Lua error fixing/editing script

What is wrong with this section and how can it be fixed - im .lua noob and have exhausted my limited knowledge of lua to solve the problem - i need you help!

function GM:Think()
        for _, ply in pairs( player.GetAll() ) do       
                if ply:IsValid() then
                        if ply:GetNWBool( "ishigh" ) then
                                if ply:GetVelocity():Length() > 0 then
                                        ply:SetVelocity( Vector( math.random( -50, 50 ), math.random( -50, 50 ), 0 ) )
                        if ply.NextO2Think == nil then
                                ply.NextO2Think = 0
                        if CurTime() > ply.NextO2Think then
                                if !ply:Alive() then return end        
                                if !ply.O2 then
                                        if ply:WaterLevel() > 0 then
                                                ply:TakeDamage( 5, ply, ply )   
                                ply.NextO2Think = CurTime() + 1

(User was banned for this post ("Wrong section" - mahalis))

You missing an ‘end’ at under the last line.

I m having issues with added weapons like the nuke launcher from the official nuke pack and any air strikes it just shoots the rocket/bomb and it dies it doesn’t shoot off and the only way to detonate it is by manually pressing the use key on it and same with smoke grenades ect from the realistic CSS weapons it throws nothing and i don’t know whats wrong

plus i downloaded the PMC npcs i think it was with all the SAS SWAT ect npcs and when i spawn them it gives me any error sign how do i fix this when i downloaded it i did all the things you’re supposed to do add materials ect

(User was banned for this post ("Thread derailing (this post belongs in Help & Support not whatever random thread you first click on)" - mahalis))

Good to know