local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait(3)
local hum = char:WaitForChild("Humanoid")
local UIS = game:GetService("UserInputService")
local goal = {FieldOfView = 90}
local Info = TweenInfo.new(0.9, Enum.EasingStyle.Sine)
local goal2 = {FieldOfView = 70}
local T = game:GetService("TweenService"):Create(game.Workspace.CurrentCamera, Info, goal)
local T2 = game:GetService("TweenService"):Create(game.Workspace.CurrentCamera, Info, goal2)
local animation2 = Instance.new("Animation")
local animation = Instance.new("Animation")
animation2.AnimationId = "rbxassetid://8835076131"
animation.AnimationId = "rbxassetid://8835065021"
local animationTrack = hum:LoadAnimation(animation)
animationTrack:Play()
UIS.InputBegan:Connect(function(Input,IsTyping,processed)
if IsTyping then return end
if processed then return end
if Input.KeyCode == Enum.KeyCode.LeftShift then
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = 32
local animationTrack2 = hum:LoadAnimation(animation2)
animationTrack2:Play()
end
end)
UIS.InputEnded:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.LeftShift then
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = 16
print("working")
T2:Play()
animationTrack:Play()
end
end)
local userInput = game:GetService("UserInputService")
local tweens = game:GetService("TweenService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local camera = workspace.CurrentCamera
local tween1 = tweens:Create(camera, TweenInfo.new(0.9, Enum.EasingStyle.Sine) , {FieldOfView = 90})
local tween2 = tweens:Create(camera, TweenInfo.new(0.9, Enum.EasingStyle.Sine) , {FieldOfView = 70})
local animation1 = Instance.new("Animation")
local animation2 = Instance.new("Animation")
animation1.AnimationId = "rbxassetid://8835076131"
animation2.AnimationId = "rbxassetid://8835065021"
local track1 = humanoid:LoadAnimation(animation1)
local track2 = humanoid:LoadAnimation(animation2)
userInput.InputBegan:Connect(function(input, processed)
if input.KeyCode == Enum.KeyCode.LeftShift then
humanoid.WalkSpeed = 32
track2:Stop()
track1:Play()
tween2:Cancel()
tween1:Play()
end
end)
userInput.InputEnded:Connect(function(input, processed)
if input.KeyCode == Enum.KeyCode.LeftShift then
humanoid.WalkSpeed = 16
track1:Stop()
track2:Play()
tween1:Cancel()
tween2:Play()
end
end)
This seems to be working for me, as suggested, you should create variables outside of the functions for the tweens/animations such that you can play/stop them accordingly when either function is executed.