Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How i can fix these problems with my sprinting script?

I noticed some errors with my sprinting script:

The sprinting animation is broken when i jump: https://media.giphy.com/media/42HL0cLbGI1wXF7jt3/giphy.gif

I can sprint whitout moving: https://media.giphy.com/media/0aT4kvX20qdm3Rjh7F/giphy.gif

Code:

local UIS = game:GetService("UserInputService")
local char = script.Parent
local cam = workspace.CurrentCamera

local runanim = Instance.new("Animation")
runanim.Name = "RunAnim"
runanim.Parent = char
runanim.AnimationId = "rbxassetid://5470703652"

local anim = char.Humanoid:LoadAnimation(char.RunAnim)

UIS.InputBegan:Connect(function(input, gameProcessed)
	if input.KeyCode == Enum.KeyCode.X then
		char.Humanoid.WalkSpeed = 30
		anim:Play()
		cam.FieldOfView = 75
	end
end)


UIS.InputEnded:Connect(function(input, gameProcessed)
	if input.KeyCode == Enum.KeyCode.X then
		char.Humanoid.WalkSpeed = 16
		anim:Stop()
		cam.FieldOfView = 70
	end
end)

2 comments

0

Ty for helping dude

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.