I Made A Tool In My Game And It Has Animations But I Also Have A Purchase Button For Ingame Currency But When The Tool Is Cloned To The Players Backpack I Get An Error In The Output Saying
Animation is not a valid member of LocalScript
And I Don’t Know Why Because It Works Fine When I Put It In Starterpack Here Is The Local Script:
local Tool = script.Parent.Parent
local player = game.Players.LocalPlayer
local character = game.Workspace:WaitForChild(player.Name)
local Humanoid = character:WaitForChild('Humanoid')
animation=Humanoid.Animator:LoadAnimation(script.Animation) -- This Is Where The Error Happends
local uses = 0
local debounce = false
local sound1 = game.ReplicatedStorage.Sounds.EatingSound1
local sound2 = game.ReplicatedStorage.Sounds.EatingSoundDone2
Tool.Equipped:Connect(function(Mouse)
Mouse.Button1Down:Connect(function()
if not debounce then
if uses == 4 then
local sound2Clone = sound2:Clone()
sound2Clone.Parent = script.Parent
sound2Clone:Play()
script.Parent.Parent:Destroy()
else
local sound1Clone = sound1:Clone()
sound1Clone.Parent = script.Parent
sound1Clone:Play()
debounce = true
animation:Play()
player.Character.Humanoid.Health += 15
uses += 1
sound1Clone:Destroy()
debounce = false
end
end
end)
end)
Thanks