Ok so. I made a shift to sprint script with a runanim and a camera zoom back. But when i jump(while im running) the run animation stops and the normal standard roblox animation for running comes... can somebody please help!
Here is the code:
local UIS = game:GetService('UserInputService')
local Player = game.Players.LocalPlayer
local Character = Player.Character
local playerModel = script.Parent
local humanoid = playerModel:WaitForChild("Humanoid")
UIS.InputBegan:connect(function(input)--When a player has pressed LeftShift it will play the animation and it will set the normal walking speed (16) to 35.
local CurrentTime = tick()
if input.KeyCode == Enum.KeyCode.LeftShift then
if humanoid.MoveDirection.Magnitude > 0 then
local ts = game:GetService("TweenService")
local info = TweenInfo.new(
1, -- Time
Enum.EasingStyle.Back, -- EasingStyle
Enum.EasingDirection.InOut, -- EasingDirection
0, -- RepeatCount (when less than zero the tween will loop indefinitely)
false, -- Reverses (tween will reverse once reaching it's goal)
0 -- DelayTime
)
local tweenObject = ts:Create(game.Workspace.CurrentCamera,info,{FieldOfView = 120})
local normal = ts:Create(game.Workspace.CurrentCamera,info,{FieldOfView = 70})
tweenObject:Play()
Character.Humanoid.WalkSpeed = 25
local Anim = Instance.new('Animation')
Anim.AnimationId = 'rbxassetid://5984101062'
PlayAnim = Character.Humanoid:LoadAnimation(Anim)
PlayAnim:Play()
else
if humanoid.MoveDirection.Magnitude == 0 then
PlayAnim:Stop()
else
PlayAnim:Play()
end
end
end
end)
UIS.InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
local ts = game:GetService("TweenService")
local info = TweenInfo.new(
1, -- Time
Enum.EasingStyle.Back, -- EasingStyle
Enum.EasingDirection.InOut, -- EasingDirection
0, -- RepeatCount (when less than zero the tween will loop indefinitely)
false, -- Reverses (tween will reverse once reaching it's goal)
0 -- DelayTime
)
local tweenObject = ts:Create(game.Workspace.CurrentCamera,info,{FieldOfView = 120})
local normal = ts:Create(game.Workspace.CurrentCamera,info,{FieldOfView = 70})
normal:Play()
Character.Humanoid.WalkSpeed = 9
PlayAnim:Stop()
end
end)

2 comments
Is the animation set to loop?
Ofc it is