I made an animation for a knife swing, but it only works in roblox studio. Help? (I used a server script to create the animation in the knife when the player joins)

-- server script

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		if plr.Backpack:FindFirstChild("Knife") then
			local swingAnim = Instance.new("Animation",plr.Backpack.Knife)
			swingAnim.AnimationId = "rbxassetid://4885168837"
			swingAnim.Name = "knifeSwing"
		elseif char:FindFirstChild("Knife") then
			local swingAnim = Instance.new("Animation",char.Knife)
			swingAnim.AnimationId = "rbxassetid://4885168837"
			swingAnim.Name = "knifeSwing"
		end
	end)
end)

--knife/tool script

script.Parent.Activated:Connect(function()
	
	local swingAnim = script.Parent:WaitForChild("knifeSwing")
	local swingTrack = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(swingAnim)
	swingTrack:Play()
	print("swing")
end)

1 comment

0

Typo: local "swingTrack =" is actually "local swingTrack = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(swingAnim)"