So basically, I have this script that heals the player fully, and I wanted to add an animation while healing, but then it completely breaks the script
Script
Tool = script.Parent
local healAnim = script.heal
local field = nil
function Heal()
local vCharacter = Tool.Parent
local childs = vCharacter:GetChildren()
local colors = {}
for i=1,#childs do
if (childs[i].className == "Part") then
colors[i] = childs[i].BrickColor
childs[i].BrickColor = BrickColor.new(1)
end
end
wait(1)
local human = vCharacter:FindFirstChild("Humanoid")
if (human ~= nil) then
human.Health = human.MaxHealth
healAnim:Play()
end
for i=1,#childs do
if (childs[i].className == "Part") then
childs[i].BrickColor = colors[i]
end
end
end
Tool.Enabled = true
function onActivated()
if not Tool.Enabled then
return
end
Tool.Enabled = false
Heal()
Tool.Parent = nil
end
script.Parent.Activated:connect(onActivated)
Solution I tried to use but didnt work, I put in a different Script that would play the animation but it didnt work either
Script:
script.Parent.Equipped:Connect(function(Mouse)
Mouse.Button1Down:Connect(function()
animation=rbxassetid://5280560587
game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
animation:Play()
end)
end)
script.Parent.Unequipped:Connect(function()
animation:Stop()
end)
