wow

Created Diff never expires
819 removals
Lines
Total
Removed
Words
Total
Removed
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
925 lines
300 additions
Lines
Total
Added
Words
Total
Added
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
408 lines
local roothidecf = CFrame.new(0, -255, 0)

if not game.IsLoaded then
if not game.IsLoaded then
game.Loaded:Wait()
game.Loaded:Wait()
end

local game = game
local debug = debug
local debug_info = debug.info

local gameIndex
local gameNewIndex

local getrawmetatableworks = false
local isindexsupported = false

if getrawmetatable then
local s, r = pcall(getrawmetatable, game)
if s then
if r.__index then
gameIndex = r.__index
gameNewIndex = r.__newindex
getrawmetatableworks = true
end
end
end

if not getrawmetatableworks then
xpcall(function()
return game[{}]
end, function()
gameIndex = debug_info(2, "f")
end)

xpcall(function()
game[{}] = {}
end, function()
gameNewIndex = debug_info(2, "f")
end)
end

local successtest, err = pcall(function()
return gameIndex(game:GetService("Workspace"), "Parent")
end)

if not successtest then
if string.find(err:lower(), "instance expected") then
isindexsupported = false
else
isindexsupported = true
end
else
isindexsupported = true
end
end
local desiredmode = false


local zeropointone = 0.1
local zeropointone = 0.1
local twait = task.wait
local twait = task.wait
local tspawn = task.spawn
local tspawn = task.spawn
local currentfakechar = nil
local currentfakechar = nil
local vector3zero = Vector3.zero
local vector3zero = Vector3.zero
local getgenv = getgenv or function()
local getgenv = getgenv or function()
return _G
return _G
end
end


local NaN = 0/0
local NaN = 0 / 0


local dummypart = Instance.new("Part")
local dummypart = Instance.new("Part")


local GetDescendants = dummypart.GetDescendants
local GetDescendants = dummypart.GetDescendants
local IsA = dummypart.IsA
local IsA = dummypart.IsA
local Destroy = dummypart.Destroy
local Destroy = dummypart.Destroy


local math_random = math.random
local math_random = math.random
local Vector3_new = Vector3.new
local Vector3_new = Vector3.new


local usedefaultanims = _G["Use default animations"] or false
local usedefaultanims = false


local transparency_level = _G["Fake character transparency level"] or 1
local transparency_level = 1


local disablescripts = _G["Disable character scripts"] or true
local disablescripts = true


local fakecollisions = _G["Fake character should collide"] or true
local fakecollisions = true


local nametoexcludefromtransparency = _G["Names to exclude from transparency"] or {}
local nametoexcludefromtransparency = {}


local parentrealchartofakechar = _G["Parent real character to fake character"] or false
local parentrealchartofakechar = false


local respawncharacter = (function() if _G["Respawn character"] == nil then return true else return _G["Respawn character"] end end)()
local respawncharacter = (function()
if _G["Respawn character"] == nil then
return true
else
return _G["Respawn character"]
end
end)()


local instantrespawn = (function() if _G["Instant respawn"] == nil then return false else return _G["Instant respawn"] end end)()
local instantrespawn = true


local LocalPlayer = game:GetService("Players").LocalPlayer
local LocalPlayer = game:GetService("Players").LocalPlayer


local exploit = "shitsploit"

if not LocalPlayer.Character then
if not LocalPlayer.Character then
LocalPlayer.CharacterAdded:Wait()
LocalPlayer.CharacterAdded:Wait()
twait(zeropointone)
twait(zeropointone)
if LocalPlayer.Character:FindFirstChildOfClass("Humanoid").RigType ~= Enum.HumanoidRigType.R6 then
if LocalPlayer.Character:FindFirstChildOfClass("Humanoid").RigType ~= Enum.HumanoidRigType.R6 then
error("Script is only compatible with R6 type rigs")
error("Script is only compatible with R6 type rigs")
return
return
end
end
end
end


local function removeAnims(character)
local function removeAnims(character)
if character == currentfakechar then
if character == currentfakechar then
return
return
end
end
local humanoid = character:WaitForChild("Humanoid", 5)
local humanoid = character:WaitForChild("Humanoid", 5)
local animator = humanoid:FindFirstChildWhichIsA("Animator")
local animator = humanoid:FindFirstChildWhichIsA("Animator")
if animator then
if animator then
Destroy(animator)
Destroy(animator)
end
end
local animateScript = character:FindFirstChild("Animate")
local animateScript = character:FindFirstChild("Animate")
if animateScript then
if animateScript then
Destroy(animateScript)
Destroy(animateScript)
end
end
local a = nil
local a = nil
a = humanoid.DescendantAdded:Connect(function(child)
a =
if child:IsA("Animator") then
humanoid.DescendantAdded:Connect(
Destroy(child)
function(child)
a:Disconnect()
if child:IsA("Animator") then
a = nil
Destroy(child)
end
a:Disconnect()
end)
a = nil
end
end
)
end
end


LocalPlayer.CharacterAdded:Once(removeAnims)
LocalPlayer.CharacterAdded:Once(removeAnims)


_G.OxideRealChar = LocalPlayer.Character
LocalPlayer.Character.Archivable = true
LocalPlayer.Character.Archivable = true
local originalChar = LocalPlayer.Character
local originalChar = LocalPlayer.Character
local fakeChar = originalChar:Clone()
local char = originalChar:Clone()
fakeChar.Name = LocalPlayer.Name .. "_Fake"
char.Name = "non"
local signaldiedbackend = LocalPlayer.ConnectDiedSignalBackend
local signaldiedbackend = LocalPlayer.ConnectDiedSignalBackend
local signalkill = LocalPlayer.Kill
local signalkill = LocalPlayer.Kill


if respawncharacter then
if respawncharacter then
if instantrespawn then
if instantrespawn then
if replicatesignal then
if replicatesignal then
replicatesignal(signaldiedbackend)
replicatesignal(signaldiedbackend)
twait(game.Players.RespawnTime - 0.05)
twait(game.Players.RespawnTime - 0.05)
replicatesignal(signalkill)
replicatesignal(signalkill)
LocalPlayer.CharacterAdded:Wait()
LocalPlayer.CharacterAdded:Wait()
fakeChar.Parent = workspace
char.Parent = workspace
currentfakechar = fakeChar
currentfakechar = char
end
end
else
else
originalChar:BreakJoints()
originalChar:BreakJoints()
LocalPlayer.CharacterAdded:Wait()
LocalPlayer.CharacterAdded:Wait()
fakeChar.Parent = workspace
char.Parent = workspace
currentfakechar = fakeChar
currentfakechar = char
end
end
end
end


twait(zeropointone)
twait(zeropointone)


local newChar = LocalPlayer.Character
local newChar = LocalPlayer.Character
newChar.Archivable = true
newChar.Archivable = true


if disablescripts then
if disablescripts then
tspawn(function()
tspawn(
for _, obj in ipairs(fakeChar:GetChildren()) do
function()
if obj:IsA("LocalScript") then
for _, obj in ipairs(char:GetChildren()) do
obj.Enabled = false
if obj:IsA("LocalScript") then
end
obj.Enabled = false
end
end
end)
end
end
)
end
end


for _, part in ipairs(fakeChar:GetDescendants()) do
for _, part in ipairs(char:GetDescendants()) do
if part:IsA("BasePart") or part:IsA("Decal") then
if part:IsA("BasePart") or part:IsA("Decal") then
if not nametoexcludefromtransparency[tostring(part)] then
part.Transparency = transparency_level
part.Transparency = transparency_level
end
end
end
end
end


twait(0.4)
twait(0.4)

LocalPlayer.Character.Parent = char
LocalPlayer.Character = fakeChar
LocalPlayer.Character = char
if parentrealchartofakechar then
if parentrealchartofakechar then
newChar.Parent = fakeChar
newChar.Parent = char
end
end
_G.OxideRealChar = char

char.Humanoid.RequiresNeck = false
char.Humanoid:SetStateEnabled(15, false)


local newcharTorso = newChar:WaitForChild("Torso")
local newcharTorso = newChar:WaitForChild("Torso")
local fakecharTorso = fakeChar:WaitForChild("Torso")
local fakecharTorso = char:WaitForChild("Torso")
local newcharRoot = newChar:WaitForChild("HumanoidRootPart")
local newcharRoot = newChar:WaitForChild("HumanoidRootPart")
local fakecharRoot = fakeChar:WaitForChild("HumanoidRootPart")
local fakecharRoot = char:WaitForChild("HumanoidRootPart")


local limbmapping = {
local limbmapping = {
Neck = fakeChar:WaitForChild("Head"),
Neck = char:WaitForChild("Head"),
RootJoint = fakeChar:WaitForChild("Torso"),
RootJoint = char:WaitForChild("Torso"),
["Left Shoulder"] = fakeChar:WaitForChild("Left Arm"),
["Left Shoulder"] = char:WaitForChild("Left Arm"),
["Right Shoulder"] = fakeChar:WaitForChild("Right Arm"),
["Right Shoulder"] = char:WaitForChild("Right Arm"),
["Left Hip"] = fakeChar:WaitForChild("Left Leg"),
["Left Hip"] = char:WaitForChild("Left Leg"),
["Right Hip"] = fakeChar:WaitForChild("Right Leg")
["Right Hip"] = char:WaitForChild("Right Leg")
}
}


local jointmapping = {
local jointmapping = {
Neck = newcharTorso:WaitForChild("Neck"),
Neck = newcharTorso:WaitForChild("Neck"),
RootJoint = newChar.HumanoidRootPart:WaitForChild("RootJoint"),
RootJoint = newChar.HumanoidRootPart:WaitForChild("RootJoint"),
["Left Shoulder"] = newcharTorso:WaitForChild("Left Shoulder"),
["Left Shoulder"] = newcharTorso:WaitForChild("Left Shoulder"),
["Right Shoulder"] = newcharTorso:WaitForChild("Right Shoulder"),
["Right Shoulder"] = newcharTorso:WaitForChild("Right Shoulder"),
["Left Hip"] = newcharTorso:WaitForChild("Left Hip"),
["Left Hip"] = newcharTorso:WaitForChild("Left Hip"),
["Right Hip"] = newcharTorso:WaitForChild("Right Hip")
["Right Hip"] = newcharTorso:WaitForChild("Right Hip")
}
}


local setdesiredangle = jointmapping["Neck"].SetDesiredAngle
local function RCA6dToCFrame(Motor6D, TargetPart, ReferencePart)
local function RCA6dToCFrame(Motor6D, TargetPart, ReferencePart)
local rel = ReferencePart.CFrame:Inverse() * TargetPart.CFrame
local rel = ReferencePart.CFrame:Inverse() * TargetPart.CFrame
local delta = Motor6D.C0:Inverse() * rel * Motor6D.C1
local delta = Motor6D.C0:Inverse() * rel * Motor6D.C1
local axis, angle = delta:ToAxisAngle()
local axis, angle = delta:ToAxisAngle()
local newangle = axis * angle
local newangle = axis * angle
sethiddenproperty(Motor6D, 'ReplicateCurrentOffset6D', delta.Position)
local offset = Vector3.zero
sethiddenproperty(Motor6D, 'ReplicateCurrentAngle6D', newangle)
if TargetPart:FindFirstChildOfClass("SpecialMesh") then
offset = TargetPart:FindFirstChildOfClass("SpecialMesh").Offset
end
sethiddenproperty(Motor6D, "ReplicateCurrentOffset6D", delta.Position + offset)
sethiddenproperty(Motor6D, "ReplicateCurrentAngle6D", newangle)
end
end


local ToObjectSpace = CFrame.new().ToObjectSpace
local ToObjectSpace = CFrame.new().ToObjectSpace
local ToEulerAnglesXYZ = CFrame.new().ToEulerAnglesXYZ
local ToEulerAnglesXYZ = CFrame.new().ToEulerAnglesXYZ
local task_spawn = task.spawn
local task_spawn = task.spawn
local function stepReanimate()
local function stepReanimate()
--// YES the code is badly formatted YES the code barely works
--// YES the code is badly formatted YES the code barely works
--// YES it is unstable. im working on a fix.
--// YES it is unstable. im working on a fix.
task_spawn(function()
for joint, limb in pairs(limbmapping) do

local realJoint = jointmapping[joint]

realJoint.MaxVelocity = 9e9
for joint, limb in pairs(limbmapping) do
local realJoint = jointmapping[joint]
if joint == "RootJoint" then
RCA6dToCFrame(realJoint, limb, fakecharRoot)
else
RCA6dToCFrame(realJoint, limb, fakecharTorso)
end
end
end
task_spawn(
function()
for joint, limb in pairs(limbmapping) do
newcharRoot.CFrame = roothidecf + Vector3_new(0, 0, math_random(1, 2) / 326.19)
newcharRoot.Velocity = vector3zero
newcharRoot.RotVelocity = vector3zero
local relativecframe = ToObjectSpace(limb.CFrame, fakecharTorso.CFrame)
local pitch, yaw, _ = ToEulerAnglesXYZ(relativecframe)
local angle = 0


newcharRoot.CFrame = fakeChar.HumanoidRootPart.CFrame + Vector3_new(0, 0, math_random(1, 2) / 326.19)
if joint == "Neck" then
newcharRoot.Velocity = vector3zero
angle = -yaw
newcharRoot.RotVelocity = vector3zero
elseif joint == "Left Shoulder" or joint == "Left Hip" then
angle = pitch
elseif joint == "Right Shoulder" or joint == "Right Hip" then
angle = -pitch
end
local realJoint = jointmapping[joint]


end)
realJoint:SetDesiredAngle(angle)
realJoint.MaxVelocity = 9e9
if joint == "RootJoint" then
RCA6dToCFrame(realJoint, fakecharTorso, newcharTorso)
else
if desiredmode == false then
RCA6dToCFrame(realJoint, limb, fakecharTorso)
end
end
end
end
)
end
end



local function setdestroyheight(height)
local function setdestroyheight(height)
local sucess, result = pcall(function()
local sucess, result =
workspace.FallenPartsDestroyHeight = height
pcall(
end)
function()
if not sucess then
workspace.FallenPartsDestroyHeight = height
end
end
)
if not sucess then
end
end
end


local currentheight = workspace.FallenPartsDestroyHeight
local currentheight = workspace.FallenPartsDestroyHeight


local function flinginternal(character, time)
local function flinginternal(character, time)
local time = time or 5
local time = time or 5

flinging = true
local start = tick()
local connection
connection = game:GetService("RunService").Heartbeat:Connect(function()
if tick() - start >= time then
setdestroyheight(currentheight)
flinging = false
connection:Disconnect()
--break
end
if character then
if character:FindFirstChild("HumanoidRootPart") then
local velocity = character.HumanoidRootPart.Velocity
local direction = velocity.Magnitude > 1 and velocity.Unit or Vector3_new(0, 0, 0)
local predictedPosition = (character.PrimaryPart.CFrame or character.HumanoidRootPart.CFrame).Position + direction * math_random(5, 12)


newcharRoot.CFrame = CFrame.new(predictedPosition)
flinging = true
newcharRoot.Velocity = Vector3_new(9e7, 9e7 * 10, 9e7)
local start = tick()
newcharRoot.RotVelocity = Vector3_new(9e8, 9e8, 9e8)
local connection
else
connection =
flinging = false
game:GetService("RunService").Heartbeat:Connect(
connection:Disconnect()
function()
--break
if tick() - start >= time then
end
setdestroyheight(currentheight)
else
flinging = false
flinging = false
connection:Disconnect()
connection:Disconnect()
--break
--break
end
end
if character then
end)
if character:FindFirstChild("HumanoidRootPart") then
local velocity = character.HumanoidRootPart.Velocity
local direction = velocity.Magnitude > 1 and velocity.Unit or Vector3_new(0, 0, 0)
local predictedPosition =
(character.PrimaryPart.CFrame or character.HumanoidRootPart.CFrame).Position +
direction * math_random(5, 12)


newcharRoot.CFrame = CFrame.new(predictedPosition)
newcharRoot.Velocity = Vector3_new(9e7, 9e7 * 10, 9e7)
newcharRoot.RotVelocity = Vector3_new(9e8, 9e8, 9e8)
else
--break
flinging = false
connection:Disconnect()
end
else
--break
flinging = false
connection:Disconnect()
end
end
)
end
end


getgenv().fling = function(character, time, yield)
getgenv().fling = function(character, time, yield)
setdestroyheight(NaN)
setdestroyheight(NaN)
local yield = yield or false
local yield = yield or false
if yield then
if yield then
flinginternal(character, time)
flinginternal(character, time)
else
else
tspawn(flinginternal, character, time)
tspawn(flinginternal, character, time)
end
end
end
end


local function disableCollisions()
local function disableCollisions()
pcall(function()
pcall(
for _, char in ipairs({ newChar }) do
function()
for _, obj in ipairs(GetDescendants(char)) do
for _, char in ipairs({newChar}) do
if IsA(obj, "BasePart") then
for _, obj in ipairs(GetDescendants(char)) do
obj.CanCollide = false
if IsA(obj, "BasePart") then
obj.Massless = true
obj.CanCollide = false
end
obj.Massless = true
end
end
end
end
end)
end
end
)
end
end


local function disableCollisionsWithFakeChar()
local function disableCollisionsWithFakeChar()
pcall(function()
pcall(
for _, char in ipairs({ newChar, fakeChar }) do
function()
for _, obj in ipairs(GetDescendants(char)) do
for _, char in ipairs({newChar, char}) do
if IsA(obj, "BasePart") then
for _, obj in ipairs(GetDescendants(char)) do
obj.CanCollide = false
if IsA(obj, "BasePart") then
obj.Massless = true
obj.CanCollide = false
end
obj.Massless = true
end
end
end
end
end)
end
end
)
end
end


local RunService = game:GetService("RunService")
local RunService = game:GetService("RunService")


RunService.Heartbeat:Connect(stepReanimate)
RunService.Heartbeat:Connect(stepReanimate)


local humanoidnewchar = newChar:WaitForChild("Humanoid")
local humanoidnewchar = newChar:WaitForChild("Humanoid")


humanoidnewchar.PlatformStand = true
humanoidnewchar.PlatformStand = true
humanoidnewchar.AutoRotate = false
humanoidnewchar.AutoRotate = false


if fakecollisions then
if fakecollisions then
RunService.PreSimulation:Connect(disableCollisions)
RunService.PreSimulation:Connect(disableCollisions)
else
else
RunService.PreSimulation:Connect(disableCollisionsWithFakeChar)
RunService.PreSimulation:Connect(disableCollisionsWithFakeChar)
end
end


workspace.CurrentCamera.CameraSubject = fakeChar:WaitForChild("Humanoid")
workspace.CurrentCamera.CameraSubject = char:WaitForChild("Humanoid")


finished = true
finished = true


if usedefaultanims then
local uis = game:GetService("UserInputService")
local script = fakeChar:FindFirstChild("Animate") or (function()
uis.InputBegan:Connect(
local temp = Instance.new("LocalScript", fakeChar)
function(k, chatting)
temp.Name = "Animate"
if chatting then
return temp
return
end)()
end

if k.KeyCode == Enum.KeyCode.Comma then
-- humanoidAnimatePlayEmote.lua
desiredmode = not desiredmode

elseif k.KeyCode == Enum.KeyCode.Minus then
local Figure = script.Parent
roothidecf = fakecharRoot.CFrame
local Torso = Figure:WaitForChild("Torso")
end
local RightShoulder = Torso:WaitForChild("Right Shoulder")
end
local LeftShoulder = Torso:WaitForChild("Left Shoulder")
)
local RightHip = Torso:WaitForChild("Right Hip")
newcharRoot.Transparency = 0.5
local LeftHip = Torso:WaitForChild("Left Hip")
local speaker = game:GetService("Players").LocalPlayer
local Neck = Torso:WaitForChild("Neck")
local Players = game:GetService("Players")
local Humanoid = Figure:WaitForChild("Humanoid")
local RunService = game:GetService("RunService")
local pose = "Standing"
antifling =

RunService.Stepped:Connect(
local EMOTE_TRANSITION_TIME = 0.1
function()

for _, player in pairs(Players:GetPlayers()) do
local userAnimateScaleRunSuccess, userAnimateScaleRunValue = pcall(function() return UserSettings():IsUserFeatureEnabled("UserAnimateScaleRun") end)
if player ~= speaker and player.Character then
local userAnimateScaleRun = userAnimateScaleRunSuccess and userAnimateScaleRunValue
for _, v in pairs(player.Character:GetDescendants()) do

if v:IsA("BasePart") then
local function getRigScale()
v.CanCollide = false
if userAnimateScaleRun then
end
return Figure:GetScale()
end
else
end
return 1
end
end
end
end
)

local seatdebounce = 3
local currentAnim = ""
local cansit = true
local currentAnimInstance = nil
char:FindFirstChild("Left Leg").Touched:Connect(
local currentAnimTrack = nil
function(p)
local currentAnimKeyframeHandler = nil
if p:IsA("Seat") and cansit == true then
local currentAnimSpeed = 1.0
local sw = Instance.new("Weld", p)
local animTable = {}
sw.Name = "SeatWeld"
local animNames = {
sw.Part0 = p
idle = {
sw.Part1 = char:FindFirstChild("HumanoidRootPart")
{ id = "http://www.roblox.com/asset/?id=180435571", weight = 9 },
sw.C0 = CFrame.new(0, 0.2, 0, 1, 0, -0, 0, 0, 1, 0, -1, 0)
{ id = "http://www.roblox.com/asset/?id=180435792", weight = 1 }
sw.C1 = CFrame.new(0, -1.5, 0, 1, 0, -0, 0, 0, 1, 0, -1, 0)
},
char:FindFirstChildOfClass("Humanoid").Sit = true
walk = {
char:FindFirstChildOfClass("Humanoid").Jumping:Wait()
{ id = "http://www.roblox.com/asset/?id=180426354", weight = 10 }
sw:Destroy()
},
char:FindFirstChildOfClass("Humanoid").Sit = false
run = {
cansit = false
{ id = "run.xml", weight = 10 }
task.spawn(
},
function()
jump = {
task.wait(seatdebounce)
{ id = "http://www.roblox.com/asset/?id=125750702", weight = 10 }
cansit = true
},
end
fall = {
)
{ id = "http://www.roblox.com/asset/?id=180436148", weight = 10 }
end
},
end
climb = {
)
{ id = "http://www.roblox.com/asset/?id=180436334", weight = 10 }
pcall(
},
function()
sit = {
char.ForceField:Destroy()
{ id = "http://www.roblox.com/asset/?id=178130996", weight = 10 }
end
},
)
toolnone = {
pcall(
{ id = "http://www.roblox.com/asset/?id=182393478", weight = 10 }
function()
},
char.OverheadGUI:Destroy()
toolslash = {
end
{ id = "http://www.roblox.com/asset/?id=129967390", weight = 10 }
)
-- { id = "slash.xml", weight = 10 }
},
toollunge = {
{ id = "http://www.roblox.com/asset/?id=129967478", weight = 10 }
},
wave = {
{ id = "http://www.roblox.com/asset/?id=128777973", weight = 10 }
},
point = {
{ id = "http://www.roblox.com/asset/?id=128853357", weight = 10 }
},
dance1 = {
{ id = "http://www.roblox.com/asset/?id=182435998", weight = 10 },
{ id = "http://www.roblox.com/asset/?id=182491037", weight = 10 },
{ id = "http://www.roblox.com/asset/?id=182491065", weight = 10 }
},
dance2 = {
{ id = "http://www.roblox.com/asset/?id=182436842", weight = 10 },
{ id = "http://www.roblox.com/asset/?id=182491248", weight = 10 },
{ id = "http://www.roblox.com/asset/?id=182491277", weight = 10 }
},
dance3 = {
{ id = "http://www.roblox.com/asset/?id=182436935", weight = 10 },
{ id = "http://www.roblox.com/asset/?id=182491368", weight = 10 },
{ id = "http://www.roblox.com/asset/?id=182491423", weight = 10 }
},
laugh = {
{ id = "http://www.roblox.com/asset/?id=129423131", weight = 10 }
},
cheer = {
{ id = "http://www.roblox.com/asset/?id=129423030", weight = 10 }
},
}
local dances = {"dance1", "dance2", "dance3"}

-- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote
local emoteNames = { wave = false, point = false, dance1 = true, dance2 = true, dance3 = true, laugh = false, cheer = false}

function configureAnimationSet(name, fileList)
if (animTable[name] ~= nil) then
for _, connection in pairs(animTable[name].connections) do
connection:disconnect()
end
end
animTable[name] = {}
animTable[name].count = 0
animTable[name].totalWeight = 0
animTable[name].connections = {}

-- check for config values
local config = script:FindFirstChild(name)
if (config ~= nil) then
-- print("Loading anims " .. name)
table.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))
table.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))
local idx = 1
for _, childPart in pairs(config:GetChildren()) do
if (childPart:IsA("Animation")) then
table.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))
animTable[name][idx] = {}
animTable[name][idx].anim = childPart
local weightObject = childPart:FindFirstChild("Weight")
if (weightObject == nil) then
animTable[name][idx].weight = 1
else
animTable[name][idx].weight = weightObject.Value
end
animTable[name].count = animTable[name].count + 1
animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
-- print(name .. " [" .. idx .. "] " .. animTable[name][idx].anim.AnimationId .. " (" .. animTable[name][idx].weight .. ")")
idx = idx + 1
end
end
end

-- fallback to defaults
if (animTable[name].count <= 0) then
for idx, anim in pairs(fileList) do
animTable[name][idx] = {}
animTable[name][idx].anim = Instance.new("Animation")
animTable[name][idx].anim.Name = name
animTable[name][idx].anim.AnimationId = anim.id
animTable[name][idx].weight = anim.weight
animTable[name].count = animTable[name].count + 1
animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
-- print(name .. " [" .. idx .. "] " .. anim.id .. " (" .. anim.weight .. ")")
end
end
end

-- Setup animation objects
function scriptChildModified(child)
local fileList = animNames[child.Name]
if (fileList ~= nil) then
configureAnimationSet(child.Name, fileList)
end
end

script.ChildAdded:connect(scriptChildModified)
script.ChildRemoved:connect(scriptChildModified)

-- Clear any existing animation tracks
-- Fixes issue with characters that are moved in and out of the Workspace accumulating tracks
local animator = if Humanoid then Humanoid:FindFirstChildOfClass("Animator") else nil
if animator then
local animTracks = animator:GetPlayingAnimationTracks()
for i,track in ipairs(animTracks) do
track:Stop(0)
track:Destroy()
end
end


for name, fileList in pairs(animNames) do
configureAnimationSet(name, fileList)
end

-- ANIMATION

-- declarations
local toolAnim = "None"
local toolAnimTime = 0

local jumpAnimTime = 0
local jumpAnimDuration = 0.3

local toolTransitionTime = 0.1
local fallTransitionTime = 0.3
local jumpMaxLimbVelocity = 0.75

-- functions

function stopAllAnimations()
local oldAnim = currentAnim

-- return to idle if finishing an emote
if (emoteNames[oldAnim] ~= nil and emoteNames[oldAnim] == false) then
oldAnim = "idle"
end

currentAnim = ""
currentAnimInstance = nil
if (currentAnimKeyframeHandler ~= nil) then
currentAnimKeyframeHandler:disconnect()
end

if (currentAnimTrack ~= nil) then
currentAnimTrack:Stop()
currentAnimTrack:Destroy()
currentAnimTrack = nil
end
return oldAnim
end

function setAnimationSpeed(speed)
if speed ~= currentAnimSpeed then
currentAnimSpeed = speed
currentAnimTrack:AdjustSpeed(currentAnimSpeed)
end
end

function keyFrameReachedFunc(frameName)
if (frameName == "End") then

local repeatAnim = currentAnim
-- return to idle if finishing an emote
if (emoteNames[repeatAnim] ~= nil and emoteNames[repeatAnim] == false) then
repeatAnim = "idle"
end

local animSpeed = currentAnimSpeed
playAnimation(repeatAnim, 0.0, Humanoid)
setAnimationSpeed(animSpeed)
end
end

-- Preload animations
function playAnimation(animName, transitionTime, humanoid)

local roll = math.random(1, animTable[animName].totalWeight)
local origRoll = roll
local idx = 1
while (roll > animTable[animName][idx].weight) do
roll = roll - animTable[animName][idx].weight
idx = idx + 1
end
-- print(animName .. " " .. idx .. " [" .. origRoll .. "]")
local anim = animTable[animName][idx].anim

-- switch animation
if (anim ~= currentAnimInstance) then

if (currentAnimTrack ~= nil) then
currentAnimTrack:Stop(transitionTime)
currentAnimTrack:Destroy()
end

currentAnimSpeed = 1.0

-- load it to the humanoid; get AnimationTrack
currentAnimTrack = humanoid:LoadAnimation(anim)
currentAnimTrack.Priority = Enum.AnimationPriority.Core

-- play the animation
currentAnimTrack:Play(transitionTime)
currentAnim = animName
currentAnimInstance = anim

-- set up keyframe name triggers
if (currentAnimKeyframeHandler ~= nil) then
currentAnimKeyframeHandler:disconnect()
end
currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)

end

end

-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------

local toolAnimName = ""
local toolAnimTrack = nil
local toolAnimInstance = nil
local currentToolAnimKeyframeHandler = nil

function toolKeyFrameReachedFunc(frameName)
if (frameName == "End") then
-- print("Keyframe : ".. frameName)
playToolAnimation(toolAnimName, 0.0, Humanoid)
end
end


function playToolAnimation(animName, transitionTime, humanoid, priority)

local roll = math.random(1, animTable[animName].totalWeight)
local origRoll = roll
local idx = 1
while (roll > animTable[animName][idx].weight) do
roll = roll - animTable[animName][idx].weight
idx = idx + 1
end
-- print(animName .. " * " .. idx .. " [" .. origRoll .. "]")
local anim = animTable[animName][idx].anim

if (toolAnimInstance ~= anim) then

if (toolAnimTrack ~= nil) then
toolAnimTrack:Stop()
toolAnimTrack:Destroy()
transitionTime = 0
end

-- load it to the humanoid; get AnimationTrack
toolAnimTrack = humanoid:LoadAnimation(anim)
if priority then
toolAnimTrack.Priority = priority
end

-- play the animation
toolAnimTrack:Play(transitionTime)
toolAnimName = animName
toolAnimInstance = anim

currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)
end
end

function stopToolAnimations()
local oldAnim = toolAnimName

if (currentToolAnimKeyframeHandler ~= nil) then
currentToolAnimKeyframeHandler:disconnect()
end

toolAnimName = ""
toolAnimInstance = nil
if (toolAnimTrack ~= nil) then
toolAnimTrack:Stop()
toolAnimTrack:Destroy()
toolAnimTrack = nil
end


return oldAnim
end

-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------


function onRunning(speed)
speed /= getRigScale()

if speed > 0.01 then
playAnimation("walk", 0.1, Humanoid)
if currentAnimInstance and currentAnimInstance.AnimationId == "http://www.roblox.com/asset/?id=180426354" then
setAnimationSpeed(speed / 14.5)
end
pose = "Running"
else
if emoteNames[currentAnim] == nil then
playAnimation("idle", 0.1, Humanoid)
pose = "Standing"
end
end
end

function onDied()
pose = "Dead"
end

function onJumping()
playAnimation("jump", 0.1, Humanoid)
jumpAnimTime = jumpAnimDuration
pose = "Jumping"
end

function onClimbing(speed)
speed /= getRigScale()

playAnimation("climb", 0.1, Humanoid)
setAnimationSpeed(speed / 12.0)
pose = "Climbing"
end

function onGettingUp()
pose = "GettingUp"
end

function onFreeFall()
if (jumpAnimTime <= 0) then
playAnimation("fall", fallTransitionTime, Humanoid)
end
pose = "FreeFall"
end

function onFallingDown()
pose = "FallingDown"
end

function onSeated()
pose = "Seated"
end

function onPlatformStanding()
pose = "PlatformStanding"
end

function onSwimming(speed)
if speed > 0 then
pose = "Running"
else
pose = "Standing"
end
end

function getTool()
for _, kid in ipairs(Figure:GetChildren()) do
if kid.className == "Tool" then return kid end
end
return nil
end

function getToolAnim(tool)
for _, c in ipairs(tool:GetChildren()) do
if c.Name == "toolanim" and c.className == "StringValue" then
return c
end
end
return nil
end

function animateTool()

if (toolAnim == "None") then
playToolAnimation("toolnone", toolTransitionTime, Humanoid, Enum.AnimationPriority.Idle)
return
end

if (toolAnim == "Slash") then
playToolAnimation("toolslash", 0, Humanoid, Enum.AnimationPriority.Action)
return
end

if (toolAnim == "Lunge") then
playToolAnimation("toollunge", 0, Humanoid, Enum.AnimationPriority.Action)
return
end
end

function moveSit()
RightShoulder.MaxVelocity = 0.15
LeftShoulder.MaxVelocity = 0.15
RightShoulder:SetDesiredAngle(3.14 /2)
LeftShoulder:SetDesiredAngle(-3.14 /2)
RightHip:SetDesiredAngle(3.14 /2)
LeftHip:SetDesiredAngle(-3.14 /2)
end

local lastTick = 0

function move(time)
local amplitude = 1
local frequency = 1
local deltaTime = time - lastTick
lastTick = time

local climbFudge = 0
local setAngles = false

if (jumpAnimTime > 0) then
jumpAnimTime = jumpAnimTime - deltaTime
end

if (pose == "FreeFall" and jumpAnimTime <= 0) then
playAnimation("fall", fallTransitionTime, Humanoid)
elseif (pose == "Seated") then
playAnimation("sit", 0.5, Humanoid)
return
elseif (pose == "Running") then
playAnimation("walk", 0.1, Humanoid)
elseif (pose == "Dead" or pose == "GettingUp" or pose == "FallingDown" or pose == "Seated" or pose == "PlatformStanding") then
-- print("Wha " .. pose)
stopAllAnimations()
amplitude = 0.1
frequency = 1
setAngles = true
end

if (setAngles) then
local desiredAngle = amplitude * math.sin(time * frequency)

RightShoulder:SetDesiredAngle(desiredAngle + climbFudge)
LeftShoulder:SetDesiredAngle(desiredAngle - climbFudge)
RightHip:SetDesiredAngle(-desiredAngle)
LeftHip:SetDesiredAngle(-desiredAngle)
end

-- Tool Animation handling
local tool = getTool()
if tool and tool:FindFirstChild("Handle") then

local animStringValueObject = getToolAnim(tool)

if animStringValueObject then
toolAnim = animStringValueObject.Value
-- message recieved, delete StringValue
animStringValueObject.Parent = nil
toolAnimTime = time + .3
end

if time > toolAnimTime then
toolAnimTime = 0
toolAnim = "None"
end

animateTool()
else
stopToolAnimations()
toolAnim = "None"
toolAnimInstance = nil
toolAnimTime = 0
end
end

-- connect events
Humanoid.Died:connect(onDied)
Humanoid.Running:connect(onRunning)
Humanoid.Jumping:connect(onJumping)
Humanoid.Climbing:connect(onClimbing)
Humanoid.GettingUp:connect(onGettingUp)
Humanoid.FreeFalling:connect(onFreeFall)
Humanoid.FallingDown:connect(onFallingDown)
Humanoid.Seated:connect(onSeated)
Humanoid.PlatformStanding:connect(onPlatformStanding)
Humanoid.Swimming:connect(onSwimming)

---- setup emote chat hook
game:GetService("Players").LocalPlayer.Chatted:connect(function(msg)
local emote = ""
if msg == "/e dance" then
emote = dances[math.random(1, #dances)]
elseif (string.sub(msg, 1, 3) == "/e ") then
emote = string.sub(msg, 4)
elseif (string.sub(msg, 1, 7) == "/emote ") then
emote = string.sub(msg, 8)
end

if (pose == "Standing" and emoteNames[emote] ~= nil) then
playAnimation(emote, 0.1, Humanoid)
end

end)

-- emote bindable hook
--[[script:WaitForChild("PlayEmote").OnInvoke = function(emote)
-- Only play emotes when idling
if pose ~= "Standing" then
return
end
if emoteNames[emote] ~= nil then
-- Default emotes
playAnimation(emote, EMOTE_TRANSITION_TIME, Humanoid)

return true, currentAnimTrack
end

-- Return false to indicate that the emote could not be played
return false
end]]
-- main program

-- initialize to idle
playAnimation("idle", 0.1, Humanoid)
pose = "Standing"


while Figure.Pare