Tool Touched Function Animation

Hello, I am currently experiencing an issue with my tool that is supposed to enable an animation. It semi works but it is incredibly unreliable. I would like for the player that holds the “Mortar” to crouch down.

Script

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Humanoid = Character:WaitForChild("Humanoid")

local Animation = script:WaitForChild("Animation")
local Track = Humanoid:LoadAnimation(Animation)
Track.Looped = true
Track.Priority = Enum.AnimationPriority.Action

local Handle = script.Parent.Handle

local function onPartTouched(Handle)

	Humanoid.WalkSpeed = 1
	Track:Play()
		
	
end


local function onPartTouchEnded(Handle)
	Humanoid.WalkSpeed = 16
	Track:Stop()
	
end


Handle.Touched:Connect(onPartTouched)
Handle.TouchEnded:Connect(onPartTouchEnded)
Video Footage

https://streamable.com/9ggmhd

What I want for it to do reliably:
image

Thanks in advance.

1 Like

Could you try to upload the video to a streaming service like youtube or streamable so we don’t have to download the video?

1 Like

Yeah, Im sorry, I never recorded a video before.

Yep thats fine, heres streamable so you can try to upload your video.

You can just use gyazo gif to show us your issue.

Nevermind, I converted it for you, just edit your post and copy and paste this link so others wont have to download a video.
https://streamable.com/9ggmhd
https:// streamable.com / 9ggmhd (get rid of the spaces and paste it)

1 Like

Mortar Tool Animation Issue - YouTube It’s uploading

1 Like

First of all, what part are you touching? I believe the touched event could be your problem.

I am trying to touch the handle of the tool.

image

This is all of the children for the tool.

Your logic confuses me, are you trying to load the animation when the tool is equipped?

Yes. I did not do Tool.Equipped because that is just when the mortar is in the backpack, I only want to activate it when the tool is in the player’s hand.

But does it not end up in the player’s hand when it’s equipped? That’s how the event works lol.

Yeah youre right lol, my bad .

Wait but, Im comfused. I used Tool.Equipped and I never even opened the tool and it is making me crouch.

So you mean only run animation when player got tool?

Yeah, when the hold the tool out.

There are many ways to do it. You can use:

  • Tool equip event
  • GetPropertyChangedSignal functions

Since you know way 1, let me explain way 2, it run your code when tool.parent is Player.Character. Or something like that.