Medkit script not working

I have a part with a ProximityPrompt that when used sends a BindableEvent to another script that should give health to the player. But currently it just deletes the medkit and doesn’t give the health for some reason.

Part with ProximityPrompt:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local healthBE = ReplicatedStorage.health

local prompt = script.Parent
local item = prompt.Parent

prompt.Triggered:Connect(function(hit)
	if not hit then return end
	if hit.Character.Humanoid.Health <= 1 then return end
	
	healthBE:Fire(hit.Character, item.healthAmount.Value, item)
end)

Event receiving script in ServerScriptService:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local healthBE = ReplicatedStorage:WaitForChild("health")

healthBE.Event:Connect(function(character, value, item)
	local player = Players:GetPlayerFromCharacter(character)
	local health = character.Humanoid.Health

	if health >= 100 then
		return
	else
		if health + value >= 100 then
			health = 100
		else
			health = health + value
		end
		
		item:Destroy()
	end
end)
1 Like

because youre only changing the health amount in the health variable, not the players humanoid

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local healthBE = ReplicatedStorage:WaitForChild("health")

healthBE.Event:Connect(function(character, value, item)
	local player = Players:GetPlayerFromCharacter(character)
	local hum = character.Humanoid

	if hum.Health >= 100 then
		return
	else
		if hum.Health + value >= 100 then
			hum.Health = 100
		else
			hum.Health = hum.Health + value
		end
		
		item:Destroy()
	end
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.