Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local module = {}
- local Dependencies_Loaded = {}
- local ModuleInfo = {
- ["Name"] = "AnimationController",
- ["Dependencies"] = {"Logging"}
- }
- function module:getName()
- return ModuleInfo.Name
- end
- function module:getDependencies()
- return ModuleInfo.Dependencies
- end
- function module.addDependency(obj)
- table.insert(Dependencies_Loaded, obj)
- end
- local function gm(str)
- for k,v in pairs(Dependencies_Loaded)do
- if v.getName() == str then
- return v
- end
- end
- end
- spawn(function()
- repeat wait() until #Dependencies_Loaded == #ModuleInfo.Dependencies
- local Logging = gm("Logging")
- Logging:Log(1, "Template loaded.")
- end)
- -- [ REMOVE OLD ANIMATION SCRIPT ] --
- pcall(function()
- game.StarterPlayer.StarterCharacterScripts:WaitForChild()("Animate"):Destroy()
- local OldAnimations = shared.Humanoid:GetPlayingAnimationTracks()
- for i,v in pairs(OldAnimations) do
- v:Stop()
- end
- end)
- local Override = false
- local State = "Idle"
- local Action = "None"
- local ActionOverride = false
- local CrouchOverride = false
- local Enabled = false
- local Animations = nil
- local UserInputService = game:GetService("UserInputService")
- -- [ STRAFE SETUP ] --
- local crouched = false
- local w = false
- local a = false
- local s = false
- local d = false
- -- [ ADD ANIMATIONS ] --
- function addAnimations()
- local Gender = shared.Character:FindFirstChild("Gender")
- if Gender.Value == "Male" then
- Animations = {
- ["WALK"] = nil,
- ["RUNNING"] = nil,
- ["IDLE"] = nil,
- ["JUMP"] = nil,
- ["FALLING"] = nil,
- ["STRAFELEFT"] = nil,
- ["STRAFERIGHT"] = nil,
- ["CROUCHFORWARD"] = nil,
- ["CROUCHLEFT"] = nil,
- ["CROUCHBACK"] = nil,
- ["CROUCHRIGHT"] = nil,
- ["CROUCHIDLE"] = nil
- }
- elseif Gender.Value == "Female" then
- Animations = {
- ["WALK"] = nil,
- ["RUNNING"] = nil,
- ["IDLE"] = nil,
- ["JUMP"] = nil,
- ["FALLING"] = nil,
- ["STRAFELEFT"] = nil,
- ["STRAFERIGHT"] = nil,
- ["CROUCHFORWARD"] = nil,
- ["CROUCHLEFT"] = nil,
- ["CROUCHBACK"] = nil,
- ["CROUCHRIGHT"] = nil,
- ["CROUCHIDLE"] = nil
- }
- end
- end
- -- [ REMOVE ANIMATIONS ] --
- function removeAnimations()
- Animations = nil
- end
- -- [ ENABLE/DISABLE ANIMATIONS ] --
- function module:Enable()
- Enabled = true
- addAnimations()
- end
- function module:Disable()
- Enabled = false
- removeAnimations()
- pcall(function()
- local DisabledAnimations = shared.Humanoid:GetPlayingAnimationTracks()
- for i,v in pairs(DisabledAnimations) do
- v:Stop()
- end
- end)
- end
- repeat wait() until Animations ~= nil
- for j,k in pairs(Animations) do
- local Animation = Instance.new("Animation")
- Animation.AnimationId = k
- Animations[j] = shared.Humanoid:LoadAnimation(Animation)
- end
- function onKeyPress(actionName, userInputState, inputObject)
- if userInputState == Enum.UserInputState.Begin and Enabled == true then
- Override = true
- if State == "Walking" then
- State = "Running"
- end
- elseif userInputState == Enum.UserInputState.End and Enabled == true then
- Override = false
- if State == "Running" then
- State = "Walking"
- end
- end
- end
- game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.LeftShift)
- UserInputService.InputBegan:connect(function(inputObject, gameProcessedEvent)
- if inputObject.KeyCode == Enum.KeyCode.W then
- w = true
- end
- if inputObject.KeyCode == Enum.KeyCode.A then
- a = true
- end
- if inputObject.KeyCode == Enum.KeyCode.S then
- s = true
- end
- if inputObject.KeyCode == Enum.KeyCode.D then
- d = true
- end
- if inputObject.KeyCode == Enum.KeyCode.C then
- crouched = true
- end
- end)
- UserInputService.InputEnded:connect(function(inputObject, gameProcessedEvent)
- if inputObject.KeyCode == Enum.KeyCode.W then
- w = false
- end
- if inputObject.KeyCode == Enum.KeyCode.A then
- a = false
- end
- if inputObject.KeyCode == Enum.KeyCode.S then
- s = false
- end
- if inputObject.KeyCode == Enum.KeyCode.D then
- d = false
- end
- if inputObject.KeyCode == Enum.KeyCode.C then
- crouched = false
- end
- end)
- spawn(function()
- if a == true then
- if crouched == false and not State == "Walking" then
- Animations.WALK:Stop()
- Animations.STRAFELEFT:Play()
- end
- elseif a == false then
- if Animations.STRAFELEFT.IsPlaying then
- Animations.STRAFELEFT:Stop()
- end
- end
- if d == true then
- if crouched == false and not State == "Walking" then
- Animations.WALK:Stop()
- Animations.STRAFERUGHT:Play()
- end
- elseif d == false then
- if Animations.STRAFERIGHT.IsPlaying then
- Animations.STRAFERIGHT:Stop()
- end
- end
- end)
- spawn(function()
- if crouched == true then
- Animations.WALK:Stop()
- Animations.RUNNING:Stop()
- if not w and not a and not s and not d then
- Animations.CROUCHIDLE:Play()
- end
- if w then
- Animations.CROUCHFORWARD:Play()
- end
- if a then
- Animations.CROUCHLEFT:Play()
- end
- if s then
- Animations.CROUCHBACK:Play()
- end
- if d then
- Animations.CROUCHRIGHT:Play()
- end
- end
- end)
- if Enabled == true then
- spawn(function()
- repeat
- wait()
- if State == "Walking" and not Animations.WALK.IsPlaying then
- Animations.WALK:Play()
- Animations.RUNNING:Stop()
- shared.Humanoid.WalkSpeed = 8
- elseif State == "Running" and not Animations.RUNNING.IsPlaying and not CrouchOverride then
- Animations.RUNNING:Play()
- Animations.WALK:Stop()
- shared.Humanoid.WalkSpeed = 26
- elseif State == "Idle" then
- Animations.WALK:Stop()
- Animations.RUNNING:Stop()
- if not Animations.IDLE.IsPlaying then
- Animations.IDLE:Play()
- end
- end
- until 1+1==3
- end)
- end
- return module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement