Help with script

Basically, I want the player to slowly heal when they click with the tool
But I’m not experienced and I want to know what’s wrong with the script
and how to fix it.
And for a animation to play when the tool is healing the player

IsHealing = false

local Tool = script.Parent
local Player = Character.Humanoid
function CheckActions(Character)

	Tool.Activated:Connect(function()
	IsHealing = not IsHealing
	if IsHealing then
	Parent.Animation:Play()		
	end
end)

if IsHealing = true then
	Player.Character.Humanoid.Health += 1
end

You’ll have to heal the player from the server and animate the tool from a local script.
LocalScript in tool:

local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animation = humanoid:LoadAnimation(script.Parent:WaitForChild("Animation"))

script.Parent.Activated:connect(function()
	animation:Play()
end)

Server Script in tool:

script.Parent.Activated:connect(function()
	script:FindFirstAncestorWhichIsA("Player").Character.Humanoid.Health += 1
end)
1 Like

what do you mean by from the server?

Something I forgot to mention in my other reply to your other post. You are unable to heal from a LocalScript. Localscripts can only modify what you see on your local computer and those changes won’t be seen from other players. This is to prevent hackers to give themselves 1000 health for example.

In order to heal, you will need a server script that actually heals. An easy way is to simply change your script into a Server Script, though this is only fine since your script is very simple.

1 Like

I updated the script to have that.

Your solution will not work if the Player clicks again to disable healing. It should keep healing until another event tells the server to stop.

There are multiple problems, one of them is that this only runs once, then you can’t heal from local script but you can animate from a local script. So try and make the healing server sided

I am on phone now so I don’t really see what else is wrong