I was trying to make a sword with an animation in a local script, but it doesnt play. There are no errrors.
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local animation = script.Parent:WaitForChild("Animatio")
local animator = character:WaitForChild("Humanoid"):WaitForChild("Animator")
local punchAnimation = animator:LoadAnimation(animation)
local canSwing = true
local debounce = 1
script.Parent.Activated:Connect(function()
if canSwing == true then
canSwing = false
punchAnimation:Play()
wait(debounce)
canSwing = true
end
end)
@geometricalC2123@Azul_Cult It still wouldn’t make any difference regardless cause Animations should be replicated via client & server I believe (And even still the LocalPlayer should be able to view the Animation on their side regardless)
@Nolas154_YT I’d check to see if the AnimationPriority in your Animation is set to Action if your other default animations could be overlapping it, either that or you’ll have to change the punchAnimation inside your Activated Event
local Plr = game.Players.LocalPlayer
local Char = Plr.Character or Plr.CharacterAdded:Wait()
local Animation = script.Parent:WaitForChild("Animation")
local Animator = Char:WaitForChild("Humanoid"):WaitForChild("Animator")
local canSwing = true
local DB = 1
script.Parent.Activated:Connect(function()
if canSwing then
canSwing = false
local PunchAnim = Animator:LoadAnimation(Animation)
PunchAnim:Play()
wait(DB)
canSwing = true
end
end)
Another possible instance is if you exactly “own” the animation or not, cause if you don’t then it’ll be unable to be played
I have set the AnimationPriority to Action, tried your script but still nothing happens without any errors. Maybe the animation doesnt work for some reason ?
It does work, maybe I did something wrong with the animation itself?
My avatar is R6 and the animation was created on a R6 template so it should work?
edit: Parent of the script is the Tool itself
local Plr = game.Players.LocalPlayer
local Char = Plr.Character or Plr.CharacterAdded:Wait()
local Animation = script.Parent:WaitForChild("Animation")
local Animator = Char:WaitForChild("Humanoid"):WaitForChild("Animator")
print("Just to make sure that everything works right")
local canSwing = true
local DB = 1
script.Parent.Activated:Connect(function()
print("Event fired")
if canSwing then
print("Attempting to load animation hopefully")
canSwing = false
local PunchAnim = Animator:LoadAnimation(Animation)
PunchAnim:Play()
wait(DB)
print("Animation finished")
canSwing = true
end
end)
Did you re-publish the Animation so that it is set to Action?