• Health Function below 10 wont work
    3 replies, posted
if LocalPlayer():Health() <= 10 then print ("21") LocalPlayer:SetBodyGroup(1, 0) elseif  LocalPlayer:SetBodyGroup(1, 1) end So basically, if your health is below 10 you lose your bodygroup. But the function doesnt even work cause my print message doesnt show up anywhere. Please help. I put this in my autorun/client/lua
It won't work because that's going to check the health as soon as the script is loaded, you'd need to put it in a think hook/timer. hook.Add("Think","Check_Player_Health",function() if LocalPlayer() and IsValid(LocalPlayer()) then if LocalPlayer():Health() <= 10 then print ("21") LocalPlayer():SetBodygroup(1, 0) elseif LocalPlayer():Health() > 10 then LocalPlayer():SetBodygroup(1, 1) end end end)
still no print message in the console, im converting it to an addon right now
This is for all my fella's out there hook.Add("Think","Check_Player_Health",function() for k, v in pairs(player.GetAll()) do   if v:Health() < 10 then     v:SetBodygroup( 1, 0 )     v:SetBodygroup( 4, 0 )     v:SetBodygroup( 5, 0 )     v:SetBodygroup( 7, 0 )     elseif v:Health() > 11 then     v:SetBodygroup( 1, 1 )   end end end)
Sorry, you need to Log In to post a reply to this thread.