Hey guys i made this script earlier today and its meant to work as a healing pad for players when they touch it.
local Medkit = script.Parent
local function onPartTouch(hit)
local Player = hit.Parent:WaitForChild("Humanoid")
local hp = Player.Health
local maxhp = Player.MaxHealth
-- local healAmount = (maxhp - hp)
if Player then
hp = maxhp --(Player.Health + healAmount)
print ("hit")
wait (1)
end
end
Medkit.Touched:Connect(onPartTouch)
It detects the player correctly as i get the print in the output however it doesn't change the players health. I have compared my script with other peoples functioning versions but I still don't understand the problem with mine. Any help would be much appreciated, thanks.

2 comments
Thanks for putting in the extra effort optimizing and putting in the comments the script is working well now.
Glad I could help!