Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local module = {}
- local uis = game:GetService("UserInputService")
- local twnService = game:GetService("TweenService")
- local runService = game:GetService("RunService")
- local setting = require(script.Parent.Important.Settings)
- local twnInfo = TweenInfo.new(.1)
- local plr = game.Players.LocalPlayer
- local cam = workspace.CurrentCamera
- local animation = script.Animation
- animation.AnimationId = setting.Sprint.SprintAnim
- local char : Model
- local hum : Humanoid
- local anim : Animator
- local spra
- local isSprint = false
- local runCon
- module.Init = function()
- char = plr.Character or plr.CharacterAdded:Wait()
- hum = char.Humanoid
- anim = hum.Animator
- spra = anim:LoadAnimation(animation)
- plr.CharacterAdded:Connect(function(c) char = c hum = c.Humanoid anim = c.Humanoid.Animator spra = c.Humanoid.Animator:LoadAnimation(animation) end)
- uis.InputBegan:Connect(function(i, g)
- if g then return end
- if i.KeyCode == setting.Sprint.SprintKey then
- isSprint = true
- hum.WalkSpeed += setting.Sprint.SprintAmount
- twnService:Create(cam, twnInfo, {FieldOfView = cam.FieldOfView + setting.Sprint.SprintFOV}):Play()
- spra:Play()
- runCon = runService.Heartbeat:Connect(function()
- if hum.MoveDirection.Magnitude > 0 then
- if isSprint then
- if not spra.IsPlaying then
- spra:Play()
- end
- end
- else
- if isSprint then
- if spra.IsPlaying then
- spra:Stop()
- end
- end
- end
- end)
- end
- end)
- uis.InputEnded:Connect(function(i, g)
- if g then return end
- if i.KeyCode == setting.Sprint.SprintKey then
- isSprint = false
- hum.WalkSpeed -= setting.Sprint.SprintAmount
- twnService:Create(cam, twnInfo, {FieldOfView = cam.FieldOfView - setting.Sprint.SprintFOV}):Play()
- spra:Stop()
- runCon:Disconnect()
- runCon = nil
- end
- end)
- end
- return module
Advertisement
Add Comment
Please, Sign In to add comment