I have a tool that plays an animation when clicked, but upon testing in game, it doesn’t work.
In game:
In studio:
Tool Script:
local tool = script.Parent
local anim = tool:WaitForChild('Animation')
local Players = game:GetService("Players")
local player
local canhit = true
local function onEquipped()
local char = tool.Parent
player = Players:GetPlayerFromCharacter(char)
end
tool.Activated:Connect(function()
if canhit == true then
canhit = false
local Character = tool.Parent
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
local Animator = Humanoid:FindFirstChildOfClass("Animator")
local leaderstats = player:WaitForChild("leaderstats")
local strength = leaderstats:WaitForChild("Strength")
local AnimationTrack = Animator:LoadAnimation(anim)
AnimationTrack:Play()
strength.Value += 100
task.wait(0.8)
canhit = true
end
end)
tool.Equipped:Connect(onEquipped)
If you look at the video, you’ll see that in game, the strength goes up. But the animation only works in the studio video
Any help would be appreciated, thanks!