local ts = game:GetService("TweenService")
local cas = game:GetService("ContextActionService")
local Humanoid = script.Parent:WaitForChild("Humanoid", 3)
local cam = workspace.CurrentCamera
local sprintAnimation = Humanoid:LoadAnimation(script:WaitForChild("RunAnimation"))
local RunSound = game.SoundService.Run
local WalkSound = game.SoundService.Walk
local isSprinting, ifSprintAnimPlay, RunSoundB, WalkSoundB = false, false, false, false
local FOVin = ts:Create(cam, TweenInfo.new(.5), {FieldOfView = 100})
local FOVout = ts:Create(cam, TweenInfo.new(.5), {FieldOfView = 70})
local function sprint(Type)
if Type == "Begin" then
isSprinting = true
Humanoid.WalkSpeed += 14
elseif Type == "Ended" then
isSprinting = false
Humanoid.WalkSpeed = 16
end
end
cas:BindAction("Sprint", function(_, inputState)
if inputState == Enum.UserInputState.Begin then
sprint("Begin")
else
sprint("Ended")
end
end, true, Enum.KeyCode.LeftShift)
cas:SetTitle("Sprint", "Sprint")
cas:SetPosition("Sprint", UDim2.new(1, -70, 0, 10))
game:GetService("RunService").RenderStepped:Connect(function()
if isSprinting and Humanoid.MoveDirection.Magnitude > 0 then
FOVin:Play()
if Humanoid:GetState() == Enum.HumanoidStateType.Running or Humanoid:GetState() == Enum.HumanoidStateType.RunningNoPhysics then
if not ifSprintAnimPlay then
sprintAnimation:Play()
ifSprintAnimPlay = true
RunSound:Play()
RunSoundB = true
WalkSound:Stop()
WalkSound = false
end
else
if ifSprintAnimPlay then
sprintAnimation:Stop()
ifSprintAnimPlay = false
RunSound:Stop()
RunSoundB = false
WalkSound:Play()
WalkSoundB = true
end
end
else
FOVout:Play()
if ifSprintAnimPlay then
sprintAnimation:Stop()
ifSprintAnimPlay = false
RunSound:Stop()
RunSoundB = false
WalkSound:Play()
WalkSoundB = true
end
end
end)
Okay, here I have an animation of running and this is what running looks like in Studio and what it looks like in Roblox
If anything, here’s where the animation itself is located
So, let’s start with the fact that I do not play all the animations in Roblocks, but again, I decided to start with running, as it is made through playing animation, not through its replacement in animate. What do you think could be the problem? (I created the animation yesterday)