Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How could I make a leaning system?

Asked by 3 years ago

What I'm trying to do is make it to where if I press "E" Or "Q" then my character leans. I already know the UserInputService stuff, I just need to know how I could make my character's head lean.

1 answer

Log in to vote
0
Answered by 3 years ago

You can make it so when you press "E" or "Q" it plays an animation. This is on a local script, and I would put it in StarterPack

local UIS = game:GetService("UserInputService")
local debounce = false
local cooldown = (add how long your cooldown would be ex: 5)
local Character =  Player.CharacterAdded:Wait()
local humanoid = Character:WaitForChild("Humanoid")
local animation = workspace.Animation --put your animation in the workspace, make sure its named Animation
animation.AnimationId = "http://www.roblox.com/asset/?id=insertAnimationIdHere"
local animationTrack = humanoid:LoadAnimation(animation)


UIS.InputBegan:Connect(function(input,isTyping)
    if isTyping then
        return
    elseif input.KeyCode == Enum.KeyCode.Q then
        if debounce == false then       
            animationTrack:Play()
            debounce = true
            wait(cooldown)
            debounce = false
        end
    end
end)
0
animation would be your character going into the lean. Make sure its on action, and its looped, so it wont end. BTW this is only to go into the lean. Im not sure how you would get out of it, but Im pretty sure you can just add another elseif statement, making the animation stop mcslimeman 37 — 3y
Ad

Answer this question