Need help for modifying player health

So I’ve been trying to create a lua script that basically just caps the player health to 100 instead of 200 and is supposed to trigger a ragdoll whenever the player gets injured. I have tried isolating multiple lines with comments to no success and am starting to beat my head over this. Anyone have an idea why it could not be working?

Thanks in advance. And yes I am relatively new to modding here so please don’t chew me out for amateur mistakes. :slight_smile:

Edit: Typos and changing format of code text.

-- Created by Scott and Eddie

-- Clientside
 Citizen.CreateThread(function()
	Citizen.Wait(10000)
	local ped = GetPlayerPed(-1) 
	local playerLoc = GetEntityCoords(GetPlayerPed(-1))
	
	SetEntityMaxHealth(GetPlayerPed(-1), 100)
	SetEntityHealth(GetPlayerPed(-1), GetEntityMaxHealth(ped))
	
	local currentHealth = GetEntityHealth(ped)
	SetAiMeleeWeaponDamageModifier(1.0)
	SetAiWeaponDamageModifier(1.0)
	SetPlayerMeleeWeaponDamageModifier(1.0)
	SetPlayerMeleeWeaponDefenseModifier(1.0)
	
	Citizen.Wait(0)

	while true do
		Citizen.Wait(0)

		ped = GetPlayerPed(-1)
		playerLoc = GetEntityCoords(GetPlayerPed(-1))
		
		SetPedCanPlayInjuredAnims(GetPlayerPed(-1), true)
		
		SetPedCanRagdollFromPlayerImpact(GetPlayerPed(-1), true)
		
		if currentHealth > GetEntityHealth(ped) then
			SetPedToRagdoll(GetPlayerPed(-1), 1000, 1000, 0, 0, 0, 0)
		end

		currentHealth = GetEntityHealth(ped) 

		if GetEntityHealth(ped) < 50 and IsPedInWrithe(ped)~=true  then
			SetPlayerControl(GetPlayerPed(-1),false,4)
			TaskWrithe(GetPlayerPed(-1), GetClosestPed(playerLoc.x, playerLoc.y, playerLoc.z, 999999.0, true, false,ped,nil,nil,-1), 300000, 0)
		end
		
	 end
end)
1 Like

Mind telling us what exactly is not working? Is it the capping of the health, triggering of the ragdoll or something else?

Literally nothing of my code is working. Could it be that I am using an outdated resource code? Maybe the server tries to emulate older libraries for scripts that were meant for older versions. That came to mind since I just modified an existing script instead of starting one from scratch.

OK, i found out that there indeed was something wrong with the resource manifest (non existent xP) and the client_scripts function wasn’t properly called.

1 Like

Hello dude, you are my last chance. Can u give the script?

1 Like