I am currently making a tool that plays an animation when it’s activated, it works perfectly fine in studio but not in game. This is not the first time it happens, i’ve tried multiple scripts and all of them lead to the same thing.
Script:
local Tool = script.Parent
local Player = game.Players.LocalPlayer -- Get local player
local Animation = script.Parent.Animation
local Chr = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Chr:WaitForChild("Humanoid")
while Humanoid and not Humanoid:IsDescendantOf(workspace) do
Humanoid.AncestryChanged:Wait()
end
local Animation = Tool.Animation
local Animator = Humanoid:WaitForChild("Animator")
local AnimTrack = Animator:LoadAnimation(Animation)
Tool.Activated:Connect(function () -- Mouse is NOT passed, that's Equipped
AnimTrack:Play()
end)
Just to remember, Humanoid:LoadAnimation() is deprecated.
Can someone please help me ?
Notes: It’s not ownership problem, i own the animation and the animation is set to Action
Who is the owner of the game and who is the owner of the animation?
If they are both the same owners then it shouldn’t be a ROBLOX issue, if it is then the owner of the game should upload the animation and you should put it in the Animation.
Why are you defining 2 times the same variable and loading the aniamtion into the animater? It think you can just load the animation onto the Humanoid.
This is quite confusing as i used the same script and it worked in both Studio and In-Game
local Tool = script.Parent
local Player = game.Players.LocalPlayer -- Get local player
local Chr = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Chr:WaitForChild("Humanoid")
while Humanoid and not Humanoid:IsDescendantOf(workspace) do
Humanoid.AncestryChanged:Wait()
end
local Animation = Tool.Animation
local Animator = Humanoid:WaitForChild("Animator")
local AnimTrack = Animator:LoadAnimation(Animation)
Tool.Activated:Connect(function() -- Mouse is NOT passed, that's Equipped
AnimTrack:Play()
end)
If the tool doesn’t have a handle then turn RequiresHandle to off.