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)
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.
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