Animations not working

Im trying to make a sword slash animation and im following this tutorial.

My problem is that the animation wont show up. I got back to Lua scripting after a Long while so im kinda “new” again but i cant find a mistake in my code maybe someone can help me.

swingAnims = {
	'rbxassetid://11414802020', --1
	'rbxassetid://11414802020', --2
	'rbxassetid://11414802020', --3
	'rbxassetid://11414802020', --4
	'rbxassetid://11414802020', --5
}

local tween_service = game:GetService("TweenService")
local replicated_storage = game:GetService("ReplicatedStorage")
local user_input_service = game:GetService("UserInputService")

local resources = replicated_storage:WaitForChild("Weapons"):WaitForChild("Katana"):WaitForChild("Default")
local fx = resources:WaitForChild("Fx")
local remote = replicated_storage:WaitForChild("Remotes"):WaitForChild("Combat")

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local root_part = character:WaitForChild("HumanoidRootPart")
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local current_swing = 1
local cooldown = false

local anim = script:WaitForChild("Animation")


local function slash(character, swing)
	
end

user_input_service.InputBegan:Connect(function(input, gpe)
	if gpe then return end
	if input.UserInputType == Enum.UserInputType.MouseButton1 and cooldown == false and character:FindFirstChild("Stun") == nil then
		
		if current_swing > 4 then
			current_swing = 1
		end
		
		cooldown = true
		print("should play animation now")
		
		anim.AnimationId = swingAnims[current_swing]
		local load = animator:LoadAnimation(anim)
		load.Priority = Enum.AnimationPriority.Action4
		load:Play()
		
		local data = {char = character, swing = current_swing, action = "slash"}
		remote:FireServer(data)
		
		slash(character, current_swing)
		current_swing = current_swing + 1
		
		task.wait(1)
		
		character.Humanoid.WalkSpeed = 16
		character.Humanoid.JumpHeight = 7.2
		cooldown = false
		
		
	end
end)

aboce is the local script for the animation

here is a screenshot of the workspace:

and here is a screenshot of the output:

2 Likes
swingAnims = {
	'rbxassetid://11414802020', --1
	'rbxassetid://11414802020', --2
	'rbxassetid://11414802020', --3
	'rbxassetid://11414802020', --4
	'rbxassetid://11414802020', --5
}

local tween_service = game:GetService("TweenService")
local replicated_storage = game:GetService("ReplicatedStorage")
local uis = game:GetService("UserInputService")

local resources = replicated_storage:WaitForChild("Weapons"):WaitForChild("Katana"):WaitForChild("Default")
local fx = resources:WaitForChild("Fx")
local remote = replicated_storage:WaitForChild("Remotes"):WaitForChild("Combat")

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local root_part = character:WaitForChild("HumanoidRootPart")
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local current_swing = 1
local cooldown = false

local anim = script:WaitForChild("Animation")


local function slash(character, swing)
	
end

uis.InputBegan:Connect(function(input, gpe)
	if gpe then return end
	if input.UserInputType == Enum.UserInputType.MouseButton1 and cooldown == false and character:FindFirstChild("Stun") == nil then
		
		if current_swing > 4 then
			current_swing = 1
		end
		
		cooldown = true
		print("should play animation now")
		
		anim.AnimationId = swingAnims[current_swing]
		local loadedanim = humanoid:LoadAnimation(anim)
		loadedanim.Priority = Enum.AnimationPriority.Action
		loadedanim:Play()
        print("anim played sucessfully")
		
		local data = {char = character, swing = current_swing, action = "slash"}
		remote:FireServer(data)
		
		slash(character, current_swing)
		current_swing = current_swing + 1
		
		task.wait(1)
		
		character.Humanoid.WalkSpeed = 16
		character.Humanoid.JumpHeight = 7.2
		cooldown = false
		
		
	end
end)

This maybe work.

1 Like

no, it still doesnt work sadly

1 Like

could you send me the game file so I can debug it?

1 Like

Baseplate.rbxl (44.8 KB)

1 Like

have you found anything that could cause the problem?

Baseplate for plr.rbxl (45.1 KB)

I was sick, sorry. (for being late)

This played fine in R15, using my own placeholder anims.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.