How would I make my character have a different idle if he's holding the ball?

Hello! I am trying to make my own blade ball game and I’ve come across this problem where I want to make it so you can catch the ball in the air and weld it to your arm however, I wanted to include that theres’ a different idle if you are with the ball. I have tried this and it doesn’t work, I’d appreciate it if someone knows how to fix it or has a script that does that

local Ball = game.Workspace.Ball


game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		for _,v in pairs(Ball:GetChildren()) do
			if v:IsA("Weld") then
				player:LoadCharacter()
				player.Character.Animate.walk.WalkAnim.AnimationId = "http://www.roblox.com/asset/?id=15309140038"
			end
		end
	end)
end)



1 Like

When the player joins the game and the character is added. They won’t have a ball in their hands yet if the objective is that they must catch the ball in the game.

You will want to setup some sort of listener/event for when the character receives a ball and then set the walk animation for the character use at that time. When they lose the ball, you’ll need to swap that animation out again.

You could do something along the lines of:

player.Character.DescendantAdded:Connect(function(part) 
    if(part == ball)then
        --Set different anim
    end
end)

Then you could do something similar with descendantRemoving. This is at least one basic way of listening for the ball given/taken from the player’s character.

2 Likes

That’s nice but the animations won’t swap at all, any suggestions on how to make them?

1 Like

There are several ways you could do this. You could create your own animation script so you don’t have to fight the default roblox script. You could set the animation priority of your walking anim higher than the default anim. You can also forcibly stop the default walking animation.

1 Like

Make a anim, make a script when the player equips and runs the anim in a loop

1 Like

Don’t think you understood.:skull_and_crossbones: lol

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