So I made a running script and it’s pretty good but my problem is that when i press shift to run then jump(press space) the running animation just doesn’t play! Does anyone know any solution for this. here is my script :
--Variables --
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Properties = {FieldOfView = 80} --Fov
local Info = TweenInfo.new(0.5, Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut) --Tween
local T =
game:GetService("TweenService"):Create(game.Workspace.CurrentCamera, Info,
Properties)
local rProperties = {FieldOfView = 70} --DefaultFov
local rInfo = TweenInfo.new(0.5, Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut) --Tween
local rT =
game:GetService("TweenService"):Create(game.Workspace.CurrentCamera, rInfo,
rProperties)
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local camerabobcf = CFrame.new()
local cam = workspace.CurrentCamera
local humanoid = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")
local UserInputService = game:GetService("UserInputService")
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://6891970873"
local RunAnim = humanoid:LoadAnimation(Animation)
local UserInputService = game:GetService("UserInputService")
-- Detect keys pressed function --
local function isKeyPressed(input)
local keysPressed = UserInputService:GetKeysPressed()
for _, key in ipairs(keysPressed) do
if key.KeyCode == input then
return true
end
end
return false
end
-- The input began --
UserInputService.InputBegan:Connect(function(inputObject, gameProcessedEvent)
if isKeyPressed(Enum.KeyCode.LeftShift ) and isKeyPressed(Enum.KeyCode.W ) then
humanoid.WalkSpeed = 30
T:Play()
RunAnim:Play()
elseif (isKeyPressed(Enum.KeyCode.W ) and isKeyPressed(Enum.KeyCode.A)) then
humanoid.WalkSpeed = 16
rT:Play()
RunAnim:Stop()
end
end)
-- The input ended --
UserInputService.InputEnded:Connect(function(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.LeftShift or inputObject.KeyCode == Enum.KeyCode.W then
player.Character.Humanoid.WalkSpeed = 16
rT:Play()
RunAnim:Stop()
end
end)