I am learning about tools and came to a problem. After reading the Hub and viewing some YouTube tutorials, i decided to try and put an animation whenever the user equips the tool, but nothing happens.
Here is the script i’ve worked with :
local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local h = char:WaitForChild("Humanoid")
local anim = h:LoadAnimation(script.Parent:WaitForChild("Equip"))
local tool = script.Parent
tool.Equipped:Connect(function()
anim:Play()
end)
tool.Unequipped:Connect(function()
anim:Stop()
end)
In order to get the LocalPlayer, you need to utilize a LocalScript, not a regular one. Generally, when ever you code anything on the client, use LocalScripts, as they were specifically designed for client/player code; including tools.
Does it not play at all? Does the first part play, then when it’s done it goes back to the default tool holding animation? edit: I just realized you’re using a server script, not a local script. You can’t play animations on the server unless you use a remote event, and you can’t get the local player either
@C_Sharper@iiFusionzX
I am truly sorry for that tiny mistake. Honestly it was around 2 am when i saw the problem.
However the animation works know but how can i make it maintain the last pose of the animation instead of coming back to the original holding animation? https://gyazo.com/42f6cd7baa7decbc3ec647e996bd0bee