Issues with creating an animation system

I tried to make a basketball system where when the ball is equipped, a dribbling animation plays. I referred to this post for doing so: How to animate Tool Parts (Guns, Knifes etc.) - #379 by ItsKoiske

When I run my scripts, it gives me an error saying that the animation ID cannot be found, when I inserted the ID of the animation that I created

I placed the basketball as a tool
image

Here are the scripts:

--Script
game.Players.PlayerAdded:Connect(function(plr)			
	plr.CharacterAdded:Connect(function(char)		
		local M6D = Instance.new("Motor6D", char.RightHand) -- or the part that you have decieded
		M6D.Name = "ToolGrip"

		char.ChildAdded:Connect(function(child)
			if child:IsA("Tool") and child:FindFirstChild("BodyAttach") then
				M6D.Part1 = child.BodyAttach
			end
		end)
	end)
end)
--LocalScript
local anim = Instance.new("Animation", script.Parent)
anim.AnimationId = "12963424741" -- id here

local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local load = char:WaitForChild("Humanoid"):LoadAnimation(anim)
script.Parent.Equipped:Connect(function()
	while true do
		wait(0.49)
		anim:Play()
	end	
end)

script.Parent.Unequipped:Connect(function()
	anim:Stop()
end)

Anyone got an idea of how I can make this work?

1 Like


Commando_Damian
DMLGDPCCTranslator

1

1m

I tried to make a basketball system where when the ball is equipped, a dribbling animation plays. I referred to this post for doing so: How to animate Tool Parts (Guns, Knifes etc.) - #379 by ItsKoiske

When I run my scripts, it gives me an error saying that the animation ID cannot be found, when I inserted the ID of the animation that I created

I placed the basketball as a tool
image

Here are the scripts:

--Script
game.Players.PlayerAdded:Connect(function(plr)			
	plr.CharacterAdded:Connect(function(char)		
		local M6D = Instance.new("Motor6D", char.RightHand) -- or the part that you have decieded
		M6D.Name = "ToolGrip"

		char.ChildAdded:Connect(function(child)
			if child:IsA("Tool") and child:FindFirstChild("BodyAttach") then
				M6D.Part1 = child.BodyAttach
			end
		end)
	end)
end)
--LocalScript
local anim = Instance.new("Animation", script.Parent)
anim.AnimationId = "rbxassetid://12963424741" -- id here

local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local load = char:WaitForChild("Humanoid"):LoadAnimation(anim)
script.Parent.Equipped:Connect(function()
	while true do
		wait(0.49)
		anim:Play()
	end	
end)

script.Parent.Unequipped:Connect(function()
	anim:Stop()
end)

I’m pretty sure u have to add this before it

1 Like

Thanks, the error is gone.
However it gives me a new error:
Play is not a valid member of Animation “Workspace.DMLGDPCC.Tool.Animation” - Client - LocalScript:11

I can’t seem to figure out how to fix that either…

--LocalScript
local anim = Instance.new("Animation", script.Parent)
anim.AnimationId = "rbxassetid://12963424741" -- id here

local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local load = char:WaitForChild("Humanoid"):LoadAnimation(anim)
script.Parent.Equipped:Connect(function()
	while true do
		wait(0.49)
		load:Play()
	end	
end)

script.Parent.Unequipped:Connect(function()
	load:Stop()
end)

here this is better

You are trying to play the animation Instance: anim:Play().
You should play the loaded animations:

local load = char:WaitForChild(“Humanoid”):LoadAnimation(anim)

So, replace :
anim:Play() with load:Play()
and
anim:Stop() with load:Stop()

1 Like

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