Right now, I have created a tool that, when activated, gives the player 10 health. However, a second after giving the player the health, it takes it away. Does anyone know why this is the case? It is a localscript placed inside a tool named "Food"
local tool = script.Parent local player = game.Players.LocalPlayer local char = player.Character local healAmount = 10 function onActivated () print("Hello") local currentHealth = char.Humanoid.Health local newHealth = currentHealth + healAmount char.Humanoid.Health = newHealth end script.Parent.Activated:Connect(onActivated)
Try this:
local tool = script.Parent local healAmount = 10 function onActivated (player) print("Hello") local char = player.Character local currentHealth = char.Humanoid.Health local newHealth = currentHealth + healAmount char.Humanoid.Health = newHealth end script.Parent.Activated:Connect(onActivated)
Put this on a server script