I am new to scripting and making gear, so I might have done a obvious mistake. I'm trying to make a healing apple, but my script does not work and there no error in the output. This is my code
local tool = game.Parent local function OnActivate() print("Player Healed") local character = tool.parent local humanoid = character.Humanoid humanoid.Health = humanoid.Health + 20 tool:Destroy() end local function OnDeactivate() print("Player has been healed") end tool.Activated:Connect(OnActivate)
if think you should do
local tool = script.Parent
not
local tool = game.Parent
the reason I think its script parent is Im guessing the script is in the tool so basically I think this would work better (this calls OnDeactivate from OnActivate)
local tool = script.Parent local function OnDeactivate() print("Player has been healed") end local function OnActivate() print("Player Healed") local character = tool.parent local humanoid = character.Humanoid humanoid.Health = humanoid.Health + 20 tool:Destroy() end tool.Activated:Connect(OnActivate)