Script not fast enough

I got a script that works and everything but when ever it stops it doesnt register fast enough, i want it to be smooth but sometimes it takes awhile to realize the player is moving, are there any alternatives for making a walk animation or anyway i can tweak the script?

_The Script

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		local humanoid = char:WaitForChild("Humanoid")
		local animator = humanoid:WaitForChild("Animator")
		local track = animator:LoadAnimation(game.ReplicatedStorage.Animations.Walk)
		track.Priority = Enum.AnimationPriority.Movement
		track.Looped = true

		humanoid.Running:Connect(function(speed)
			if speed > 0 then
				if not track.IsPlaying then
					track:Play()
				end
			else
				if track.IsPlaying then
					track:Stop()
				end
			end
		end)
	end)
end)
1 Like

Roblox allows you to actually modify default animations, all you would need to do is modify a value in a roblox script and don’t even have to code anything. Here’s how:

1 Like

something like this would work, you just have to get the humanoid or rootpart

local RunService = game:GetService("RunService")
local Vector = Vector3.new(1, 0, 1)

RunService:BindToRenderStep("Animator", Enum.RenderPriority.Character.Value+2, function()
	
	local Velocity = (Humanoid.RootPart.AssemblyLinearVelocity*Vector).Magnitude -- Get Player Horizontal Velocity.

	if Velocity > 1 then
		-- play animation.
	else
		-- stop animation.
	end
end)

I have answered this question before:

MoveDirection is actually faster

works perfectly, thanks for the help!

1 Like