Error on hud script

Im getting a error with this and I dont even get what the error means, its from this script
[Lua]
local function WeaponInfo()
draw.SimpleText("Ammo: "…gamemode.Call(“GetAmmo”,2), “ScoreboardText”,ScrW()/2,ScrH()/2, Color(255,0,0), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end
[/Lua]
The error is “attempt to concatenate a boolean value”

Usually errors in Garrysmod are very descriptive and easy to figure out, including yours.

Concatenate basically means combining strings, so you can see on line 2 you’re concatenating "Ammo: " with gamemode.Call(“GetAmmo”, 2).

This error is occurring for two reasons:

  1. You’re not using gamemode.Call() correctly. gamemode.Call() is used to run a gamemode hook, for instance, if you wanted to run the code hooked to “PlayerSpawn” without the player needing to respawn, you could do gamemode.Call(“PlayerSpawn”, player). What you should be using to get the player’s ammo is Player:GetAmmoCount()

  2. The source of your actual error is that gamemode.Call() returns a boolean value, and for some reason Garrysmod cant automatically concatenate booleans like it can strings and numbers. So just wrap what you’re concatenating (gamemode.Call()) in tostring() and it will be converted to a string, ready to concatenate.

Though, if you use the correct call (Player:GetAmmoCount()) you’ll get a number instead of a bool and wont need to use tostring() after all.

Phew that was a lot of words :v:

thanks, I am using a different ammo count system as it counts how many entities you are aloud but it works now thanks