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)