[Help] Writing a script for an item that heals you, what do I change?

So in my client.lua script I got

RegisterNetEvent(‘esx_bread:bread’)
AddEventHandler(‘esx_bread:bread’, function()
local playerPed = GetPlayerPed(-1)
Citizen.CreateThread(function()
SetPedHealth(playerPed, 100)
end)
end)

Then in my server.lua script I got

ESX = nil

ESX.RegisterUsableItem(‘bread’, function(source)
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.removeInventoryItem(‘bread’, 1)
TriggerClientEvent(‘esx_bread:bread’, source)
end)

I believe the server.lua is fine as the bread is usable, but I don’t think “SetPedHealth” is actually a command like SetPedArmour is.

Any help would be greatly appreciated, this is the last feature my server needs before I can make it live.

SET_ENTITY_HEALTH https://runtime.fivem.net/doc/natives/#_0x6B76DC1F3AE6E6A3

1 Like

So all the same except replace setpedhealth(playerped, 100) to SET_ENTITY_HEALTH(100)?

SetEntityHealth(GetPlayerPed(-1),100)

Beautiful man. Thank you.

anyone know how to make an item not heal instantly but rejuvenate ur health over time