Ok so here are my 2 scripts one for the camera and another for the running (note that i didn’t make the stamina system yet!)
(—Running 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()
humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
humanoid.WalkSpeed = 16
rT:Play()
RunAnim:Stop()
end)
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)
(—Camera script—)
local camerabobcf = CFrame.new()
local cam = workspace.CurrentCamera
local humanoid = game.Players.LocalPlayer.Character:FindFirstChild(“Humanoid”)
local UserInputService = game:GetService(“UserInputService”)
game:GetService(“RunService”).RenderStepped:Connect(function()
cam.CFrame = cam.CFrame
* camerabobcf
if humanoid.MoveDirection.Magnitude > 0 then
camerabobcf = camerabobcf:Lerp(CFrame.new() * CFrame.Angles(
0,
0,
0.02 * math.sin(tick() * 8)) -- intensity * math.sin(tick() * speed))
,.1)
end
end)