I have been making a hud recently and is there a way to make something like this :local health = LocalPlayer():Health() but getting the local players ammo?
Clip: LocalPlayer():GetActiveWeapon():Clip1() or Clip2()
Reserve: LocalPlayer():GetAmmoCount( LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType() or GetSecondaryAmmoType() )
That doesn't seem to be working.
Heres the code I'm using for the HP bar:
It doesnt seem to be working?
Heres what I'm using for the HP bar.
local health = LocalPlayer():Health()
draw.RoundedBox(0,10,650,health * 3,30,Color(255,0,1))
draw.SimpleText(health.."%","Whatever",10 +150 ,10 + 656,Color(255,255,255),1,1)
Tell us what's not working.
The bar is not working.
[ERROR]
1. unknown - [C]:-1
Error in hook HUDPaint: lua/testing.lua:34: attempt to call method 'Clip1' (a nil value)
stack traceback:
lua/testing.lua:34: in function 'fn'
addons/ulib/lua/ulib/shared/hook.lua:110: in function <addons/ulib/lua/ulib/shared/hook.lua:93>
[C]: in function '•‎​‬‪•'
[ERROR]
1. unknown - [C]:-1
[editline]29th July 2016[/editline]
Heres what Im trying to do :
local clip1 = LocalPlayer():Clip1()
draw.RoundedBox(0,10,650,Clip1 * 3,30,Color(255,0,1))
LocalPlayer():GetActiveWeapon():Clip1()
Clip1() needs a weapon object, not player
What do you mean by a weapon object? (Sorry Im still learning lua)
LocalPlayer() returns the player
Clip1() is used on a weapon, not player, so if you use LocalPlayer():Clip1(), it is going to error.
However, GetActiveWeapon() is used on a player, and returns the weapon the player is currently holding. You will combine those to get the final result:
[code]LocalPlayer():GetActiveWeapon():Clip1()[/code]
Sorry, you need to Log In to post a reply to this thread.