Quick actions

cmd+k|ctrl+k

Navigation

Languages

r15 welds

Snippet info

Language

Lua

Visibility

public

Author

dinoturto

Created

2020-08-10T23:01:28Z

Updated

2024-03-08T03:22:11.789837Z

local chr = owner.Character
local root = chr.HumanoidRootPart

function joint(p0, p1, c0, c1)
    local w = Instance.new("Weld")
    w.Part0 = p0
    w.Part1 = p1
    w.C0 = c0
    w.C1 = c1
    w.Parent = p0
    return w
end

nk = joint(chr.UpperTorso, chr.Head, CFrame.new(0, 0.95, 0), CFrame.new(0, -0.475, 0))
rj = joint(root, chr.LowerTorso, CFrame.new(0, -0.125, 0), CFrame.new(0, 0.55, 0))
ws = joint(chr.LowerTorso, chr.UpperTorso, CFrame.new(0, 0.1, 0), CFrame.new(0, -0.7, 0))
rs = joint(chr.UpperTorso, chr["RightUpperArm"], CFrame.new(1.5, 0.75, 0), CFrame.new(0, 0.5, 0))
ls = joint(chr.UpperTorso, chr["LeftUpperArm"], CFrame.new(-1.5, 0.75, 0), CFrame.new(0, 0.5, 0))
re = joint(chr["RightUpperArm"], chr["RightLowerArm"], CFrame.new(0, -0.3, 0), CFrame.new(0, 0.25, 0))
le = joint(chr["LeftUpperArm"], chr["LeftLowerArm"], CFrame.new(0, -0.3, 0), CFrame.new(0, 0.25, 0))
rw = joint(chr["RightLowerArm"], chr["RightHand"], CFrame.new(0, -0.3, 0), CFrame.new(0, 0.3, 0))
lw = joint(chr["LeftLowerArm"], chr["LeftHand"], CFrame.new(0, -0.3, 0), CFrame.new(0, 0.3, 0))
rh = joint(chr.LowerTorso, chr["RightUpperLeg"], CFrame.new(0.5, -0.35, 0), CFrame.new(0, 0.35, 0))
lh = joint(chr.LowerTorso, chr["LeftUpperLeg"], CFrame.new(-0.5, -0.35, 0), CFrame.new(0, 0.35, 0))
rk = joint(chr["RightUpperLeg"], chr["RightLowerLeg"], CFrame.new(0, -0.4, 0), CFrame.new(0, 0.37, 0))
lk = joint(chr["LeftUpperLeg"], chr["LeftLowerLeg"], CFrame.new(0, -0.4, 0), CFrame.new(0, 0.37, 0))
ra = joint(chr["RightLowerLeg"], chr["RightFoot"], CFrame.new(0, -0.3, 0), CFrame.new(0, 0.3, 0))
la = joint(chr["LeftLowerLeg"], chr["LeftFoot"], CFrame.new(0, -0.3, 0), CFrame.new(0, 0.3, 0))

nkc0, rjc0, wsc0 = nk.c0, rj.c0, ws.c0
lsc0, lec0, lwc0, rsc0, rec0, rwc0 = ls.c0, le.c0, lw.c0, rs.c0, re.c0, rw.c0
lhc0, lkc0, lac0, rhc0, rkc0, rac0 = lh.c0, lk.c0, la.c0, rh.c0, rk.c0, ra.c0

local joints = {
    ["nk"] = nk, ["rj"] = rj, ["ws"] = ws,
    ["ls"] = ls, ["le"] = le, ["lw"] = lw, ["rs"] = rs, ["re"] = re, ["rw"] = rw,
    ["lh"] = lh, ["lk"] = lk, ["la"] = la, ["rh"] = rh, ["rk"] = rk, ["ra"] = ra
}

local t = os.clock()
local dt = os.clock()
local exactVel = 0
local vel = 0
local animMove = true
local action = "Idle"

local animTable = {
    ["Idle"] = function() return {
            ["rj"] = rjc0,
            ["ws"] = wsc0,
            ["nk"] = nkc0,
            ["ls"] = lsc0,
            ["le"] = lec0,
            ["lw"] = lwc0,
            ["rs"] = rsc0,
            ["re"] = rec0,
            ["rw"] = rwc0,
            ["lh"] = lhc0,
            ["lk"] = lkc0,
            ["la"] = lac0,
            ["rh"] = rhc0,
            ["rk"] = rkc0,
            ["ra"] = rac0
    } end;
    
}

game:GetService("RunService").PostSimulation:Connect(function(delta)
    dt = delta
    t = os.clock() * 60
    
    exactVel = CFrame.new(root.CFrame:VectorToObjectSpace(root.Velocity))
    vel = Vector3.new(math.clamp(exactVel.x, -32, 32), math.clamp(exactVel.y, -32, 32), math.clamp(exactVel.z, -32, 32))
    
    for i, v in joints do
        v.C0 = animTable[action]()[i]
    end
end)
INFO