i want to make a sword that plays its animation when its activated. Im actually bad at creating weapons so i used this tutorial.
https://www.youtube.com/watch?v=sC84mj1-h9Y
Weapon animation plays only when the tool is picked up from workspace, but it's animation is not working when it's in starterpack.
Error message: Players.me.Backpack.Script:6: attempt to index nil with 'Character' - Server - Script:6
Im posting the script below.
wait(4)
local player = game:GetService("Players").LocalPlayer
local character = player.Character
local animation = script.Parent:FindFirstChild("Animation")
local swingAnimation = character.Humanoid:LoadAnimation(animation)
local canSwing = true
local debounce = 1
script.Parent.Activated:Connect(function()
if canSwing then
canSwing = false
swingAnimation:Play()
wait(debounce)
canSwing = true
end
end)

6 comments
i already did it but it did not work
What error are you getting now
The script has to be in a local script. Run the script with the code in a local script and tell me what error you're getting
Oh! wait it works, i just forgot refresh, thanks!
bruh lol. accept my invite pls so i can get them sweet rep points
ok lol