I don't really like that my humanoid in my game continues to sprint even if it jumps, so I tried integrating a script that would stop the animation if space is detected through the system, but I was unsuccessful. Here are my scripts.
ocal toggleSprintEvent = game.ReplicatedStorage:WaitForChild("ToggleSprint")
toggleSprintEvent.OnServerEvent:Connect(function(player, turnOnSprint)
local char = player.Character
if not char:FindFirstChild("Humanoid") then return end
if turnOnSprint == true then
char:FindFirstChild("Humanoid").WalkSpeed = 50
local sprintAnim = Instance.new("Animation")
sprintAnim.AnimationId = 'rbxassetid://5150687024'
playAnim = char.Humanoid:LoadAnimation(sprintAnim)
playAnim:Play()
else
char:FindFirstChild("Humanoid").WalkSpeed = 16
playAnim:Stop()
end
end)
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.Space
then
playAnim:Stop()
end
end)

3 comments
maybe do something like Humanoid.Changed:Connect(function() if Char:FindFirstChild("Humanoid").Jump == true then if char.Humanoid.turnOnSprint == true then char.Humanoid.Walkspeed = 16
which line would I try that at?
I'm not too sure on that, maybe after the end on line 21 or 20, just test and see how it goes. Make sure to open the output to see what happens. and also, don't forget to put 2 (or maybe 3) ends after the statement. If you are having more problems then tell me