Не нажимайте на это! / @mazesunshine3946
Скрипт:
local Player=game.Players.LocalPlayer — Получение игрока [Работает только в LocalScripts]
local UserInputService=game:GetService("UserInputService") — Служба обнаружения ввода
local TweenService=game:GetService("TweenService") — Служба плавного перехода между свойствами
-[[]]-
local IsSprinting=false — Игрок по умолчанию не бежит
local Settings={
["NormalSpeed" 16; — Скорость ходьбы игрока по умолчанию
["SprintSpeed" 25; — Скорость во время бега
["NormalFov" 70; — Поле зрения игрока по умолчанию
["SprintFov" 82; -- Поле зрения игрока, бегущего спринтом
}
-[[]]-
local function StartSprinting()
if not Player.Character then
-- У игрока нет персонажа
return
end
if not Player.Character:FindFirstChild("HumanoidRootPart") then
-- Игрок мёртв
return
end
if IsSprinting==true then
-- Игрок уже бежит спринтом
return
end
IsSprinting=true
TweenService:Create(workspace['CurrentCamera'],TweenInfo.new(0.4,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0),{FieldOfView=Settings.SprintFov}):Play()
TweenService:Create(Player.Character.Humanoid,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0),{WalkSpeed=Settings.SprintSpeed}):Play()
end
UserInputService.InputBegan:Connect(function(Input,GameProcessed)
if GameProcessed then
Пользователь пишет в чате
return -- Предотвратить выполнение дальнейшего кода
end
if Input.KeyCode==Enum.KeyCode.LeftShift then -- Игрок нажал LeftShift
StartSprinting()
end
end)
-[[]]-
local function StopSprinting()
if IsSprinting==false then
Игрок не бежит
return
end
IsSprinting=false
TweenService:Create(workspace['CurrentCamera'],TweenInfo.new(0.5,Enum.EasingStyle.Back,Enum.EasingDirection.Out,0,false,0),{FieldOfView=Settings.NormalFov}):Play()
TweenService:Create(Player.Character.Humanoid,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0),{WalkSpeed=Settings.NormalSpeed}):Play()
end
UserInputService.InputEnded:Connect(function(Input,GameProcessed)
if GameProcessed then
-- Пользователь пишет в чате
return -- Предотвратить запуск дальнейшего кода
end
if Input.KeyCode==Enum.KeyCode.LeftShift then -- Игрок отпустил LeftShift
StopSprinting()
end
end)
-- Maze Sunshine Одобрено
Информация по комментариям в разработке