How can I get my sprint script to tell when a player has equipped a specific tool? (edit)

(edit) I noticed a problem with my local script, I need my sprint script to tell when a player equips a specific tool to stop the player from running. I’ve tried solutions like:

script.Parent.ChildAdded:connect(function(p)
	if p:IsA('Tool')then
		print("Found")
	end
end)

But I don’t know how to make it work only for one tool.

local character = script.Parent
local hum = character:WaitForChild("Humanoid")

local con = game:GetService("ContextActionService")

local running = false

local runAnim= Instance.new("Animation")
runAnim.AnimationId = "rbxassetid://6324771825"

local load = hum:LoadAnimation(runAnim)


local function handler(actionName, inputState, inputObject)
	if actionName == "Run" then
		if inputState == Enum.UserInputState.Begin then
			hum.WalkSpeed = 26 
			load:Play()
			running = true
		end
		if inputState == Enum.UserInputState.End then
			if load.IsPlaying then
				load:Stop()
			end
			hum.WalkSpeed = 16
			running = false
		end
	end
end

con:BindAction("Run", handler, false, Enum.KeyCode.LeftShift)

while wait() do 
	if hum.MoveDirection.Magnitude <= 0 and running then
		if load.IsPlaying then
			load:Stop()
		end
		hum.WalkSpeed = 16
		running = false
	end
end

while wait() do 
	script.Parent.Combat.Blocking:WaitForChild("RemoteEvent").OnServerEvent:Connect(function()
		if running == true and load.IsPlaying then
			load:Stop()
		end
		hum.WalkSpeed = 10
		running = false
		print("this worked")
		end)
end

hum.Jumping:Connect(function(active)
	if active == false and running == true then
		load:Play()
	end
end)

Sprint script

1 Like

Try using AnimationTrack:Stop()

1 Like

I guess I forgot to mention that the print doesn’t work which means that the

	script.Parent.Combat.Blocking:WaitForChild("RemoteEvent").OnServerEvent:Connect(function()
		if running == true and load.IsPlaying then
			load:Stop()
		end
		hum.WalkSpeed = 10
		running = false
		print("this worked")
		end)
end 

Part doesn’t work or go through

Nvm found it myself, just used a regular script and remote event