New to lua coding, What is wrong here?

I am attempting to code a admin has joined the server script however i am getting script errors

This is probably such a simple fix but it would help and educate me if i was told the problem here. Thankyou


function GM:PlayerInitalSpawn( ply )
if ply:IsUserGroup "superadmin" then
print (HUD_PRINTTALK, "Superadmin" ply:Nick() "has joined!")
end

end


 ')' expected near 'ply'

Change


if ply:IsUserGroup "superadmin" then


HUD_PRINTTALK, "Superadmin" ply:Nick() "has joined!")

to


if ply:IsUserGroup("superadmin") then


HUD_PRINTTALK, "Superadmin".. ply:Nick().. "has joined!")


function GM:PlayerInitalSpawn( ply )

    if ply:IsUserGroup( "superadmin" ) then

        print( "Superadmin " .. ply:Nick() .. " has joined!" )

    end

end 

cheers champ. sorry to bother you, just needed some guidence



hook.Add("PlayerInitialSpawn", "SuperAdminCheck", function(ply)
    if ply:IsUserGroup() == "superadmin" then
        PrintMessage(HUD_PRINTTALK, "Superadmin"..ply:Nick().."has joined!")
    end
end)


[editline]30th July 2016[/editline]

ninja’d two times, jesus christ

[editline]30th July 2016[/editline]

You might want to use a hook by the way, the thing above overwrites PlayerInitialSpawn entirely

Agreed with MPan, you’d want to put your code in


hook.Add("PlayerInitialSpawn", "SuperAdminCheck", function(ply)

//Code here

end)

cheers again lads