You did not get the ProximityPromptService in your script
LocalPlayer cannot be used in a Server Script
Humanoid is always inside a Player’s Character
There are several was you could do that and in different instances. Put this code inside a server script.
Increasing player’s health by a fixed value-
local ProximityPromptService = game:GetService("ProximityPromptService")
local ProximityPrompt = script.Parent
local incrementValue = 20 --can be changed to any value depending upon how much health you want to increase
ProximityPrompt.Triggered:Connect(function(player)
workspace[player.Name].Humanoid.Health = workspace[player.Name].Humanoid.Health + incrementValue
print("Health increased")
end)
Increasing player’s health to the maximum health possible
local ProximityPromptService = game:GetService("ProximityPromptService")
local ProximityPrompt = script.Parent
ProximityPrompt.Triggered:Connect(function(player)
local maxHealth = workspace[player.Name].Humanoid.MaxHealth
workspace[player.Name].Humanoid.Health = maxHealth
print("Health Full")
end)
Increasing player health by a value until its full
local ProximityPromptService = game:GetService("ProximityPromptService")
local ProximityPrompt = script.Parent
local incrementValue = 10
ProximityPrompt.Triggered:Connect(function(player)
local maxHealth = workspace[player.Name].Humanoid.MaxHealth
while workspace[player.Name].Humanoid.Health < maxHealth do
wait(0.5)
workspace[player.Name].Humanoid.Health = workspace[player.Name].Humanoid.Health + incrementValue
end
print("Health Full")
end)