Gamemode Lua Error.

Hey guys this is my first time posting soo…

Anyways, I was testing my gamemode and when I tested it online my friend keep getting this message

So i’m guessing this code is creating the error.

I’m new and this is my first time coding, so i’m probably doing something wrong.

Make sure it’s in if CLIENT tags, it is a client-only method

Usage example would be this.

http://puu.sh/3qQ5W.jpg

I keep getting the same error, here are some pics of my code and my error

Here’s my code

Here’s my error whenever someone dies

I believe if someone is dead then they won’t have an active weapon, so you can’t get the name from it.
Check if they are alive (or if they actually have a weapon).
Something like


local weapon = LocalPlayer():Alive() and LocalPlayer():GetActiveWeapon() and LocalPlayer:GetActiveWeapon():GetPrintName() or "No weapon"

The alive check isn’t really needed if you are also checking if the weapon is valid, it could just be


local weapon = LocalPlayer():GetActiveWeapon() and LocalPlayer:GetActiveWeapon():GetPrintName() or "No weapon"

You forgot brackets


local weapon = LocalPlayer():Alive() and LocalPlayer():GetActiveWeapon() and LocalPlayer():GetActiveWeapon():GetPrintName() or "No weapon"

Thanks, fixed it with this code


	
if LocalPlayer():GetActiveWeapon():IsWeapon() then
draw.SimpleText(LocalPlayer():GetActiveWeapon():GetPrintName(), "Trebuchet24", 12, ScrH() - 95, Color(255,255,255,255))
else
draw.SimpleText("No Weapon", "Trebuchet24", 12, ScrH() - 95, Color(255,255,255,255))		
end