View difference between Paste ID: QbP6Zbew and e4GU31Sv
SHOW: | | - or go back to the newest paste.
1-
--[[
1+
torso = game.Players.LocalPlayer.Character:FindFirstChild("Torso")
2-
   Original creator might be: not sure
2+
if torso then
3-
   Edit by: dak#1111
3+
game.Players.LocalPlayer.Character.Torso["Right Shoulder"]:Destroy()
4
game.Players.LocalPlayer.Character.Torso["Left Shoulder"]:Destroy()
5-
   Made it less aids to read + some quality of life changes. :p
5+
game.Players.LocalPlayer.Character.Torso["Right Hip"]:Destroy()
6-
   (Who ever made this, for the love of god learn to not make spaghetti.)
6+
game.Players.LocalPlayer.Character.Torso["Left Hip"]:Destroy()
7-
--]]
7+
else
8
game.Players.LocalPlayer.Character.RightUpperArm["RightShoulder"]:Destroy()
9-
-- Variables and setting up the character
9+
game.Players.LocalPlayer.Character.LeftUpperArm["LeftShoulder"]:Destroy()
10-
local rs = game:GetService("RunService")
10+
game.Players.LocalPlayer.Character.RightUpperLeg["RightHip"]:Destroy()
11
game.Players.LocalPlayer.Character.LeftUpperLeg["LeftHip"]:Destroy()
12-
local plr  = game:GetService("Players").LocalPlayer
12+
13-
local char = plr.Character
13+
headoffset=CFrame.Angles(0,math.rad(32),0)
14-
char.Archivable = true
14+
la = game.Players.LocalPlayer.Character:FindFirstChild("Left Arm")or game.Players.LocalPlayer.Character:FindFirstChild("LeftUpperArm")
15-
local cam  = workspace:WaitForChild("Camera")
15+
ra = game.Players.LocalPlayer.Character:FindFirstChild("Right Arm")or game.Players.LocalPlayer.Character:FindFirstChild("RightUpperArm")
16
local singulartorso = false
17-
local fakechar = char:Clone()
17+
local t
18-
fakechar.Head.face.Texture = ""
18+
local ut
19-
fakechar.Parent = workspace
19+
local lt
20-
cam.CameraSubject = fakechar:FindFirstChildOfClass("Humanoid")
20+
local WeldBase = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")
21
if true then 
22-
local connections = {}
22+
	singulartorso = true
23-
local kill = false
23+
	t = game.Players.LocalPlayer.Character:FindFirstChild("Torso") or game.Players.LocalPlayer.Character:FindFirstChild("UpperTorso")
24
end
25-
-- Align function
25+
rl = game.Players.LocalPlayer.Character:FindFirstChild("Right Leg")or game.Players.LocalPlayer.Character:FindFirstChild("RightUpperLeg")
26-
local function Align(Part1, Part0, Position, Angle)
26+
ll = game.Players.LocalPlayer.Character:FindFirstChild("Left Leg")or game.Players.LocalPlayer.Character:FindFirstChild("LeftUpperLeg")
27-
   Part1.CanCollide = false
27+
local h1
28
local h2
29-
   local AlignPos = Instance.new("AlignPosition")
29+
local h
30-
   AlignPos.ApplyAtCenterOfMass = true
30+
if t then
31-
   AlignPos.MaxForce = 100000
31+
else
32-
   AlignPos.MaxVelocity = math.huge
32+
33-
   AlignPos.ReactionForceEnabled = false
33+
game.Players.LocalPlayer.Character.Head.CanCollide=false
34-
   AlignPos.Responsiveness = 200
34+
game.Players.LocalPlayer.Character.Head:GetPropertyChangedSignal("CanCollide"):Connect(function()
35-
   AlignPos.RigidityEnabled = false
35+
    game.Players.LocalPlayer.Character.Head.CanCollide=false
36-
   AlignPos.Parent = Part1
36+
37
if game.Players.LocalPlayer.Character:FindFirstChild("LowerTorso") then
38-
   local AlignOri = Instance.new("AlignOrientation")
38+
    game.Players.LocalPlayer.Character.LowerTorso.CanCollide=false
39-
   AlignOri.MaxAngularVelocity = math.huge
39+
    game.Players.LocalPlayer.Character.LowerTorso:GetPropertyChangedSignal("CanCollide"):Connect(function()
40-
   AlignOri.MaxTorque = 100000
40+
        game.Players.LocalPlayer.Character.LowerTorso.CanCollide=false
41-
   AlignOri.PrimaryAxisOnly = false
41+
    end)
42-
   AlignOri.ReactionTorqueEnabled = false
42+
    game.Players.LocalPlayer.Character.UpperTorso.CanCollide=false
43-
   AlignOri.Responsiveness = 200
43+
    game.Players.LocalPlayer.Character.UpperTorso:GetPropertyChangedSignal("CanCollide"):Connect(function()
44-
   AlignOri.RigidityEnabled = false
44+
        game.Players.LocalPlayer.Character.UpperTorso.CanCollide=false
45-
   AlignOri.Parent = Part1
45+
    end)
46
else
47-
   local at1 = Instance.new("Attachment")
47+
    game.Players.LocalPlayer.Character.Torso.CanCollide=false
48-
   at1.Parent = Part1
48+
    game.Players.LocalPlayer.Character.Torso:GetPropertyChangedSignal("CanCollide"):Connect(function()
49-
   local at2 = Instance.new("Attachment")
49+
        game.Players.LocalPlayer.Character.Torso.CanCollide=false
50-
   at2.Parent = Part0
50+
    end)
51-
at2.Orientation = Angle
51+
52-
   at2.Position = Position
52+
local char = game:GetObjects("rbxassetid://5195737219")[1]
53-
   
53+
char.Parent = game.Players.LocalPlayer.Character
54-
   AlignPos.Attachment0 = at1
54+
for i,v in pairs(char:GetDescendants()) do
55-
   AlignPos.Attachment1 = at2
55+
    if v:IsA("BasePart") then
56-
   AlignOri.Attachment0 = at1
56+
        local prt=v
57-
   AlignOri.Attachment1 = at2
57+
        prt:GetPropertyChangedSignal("Transparency"):Connect(function()
58
            prt.Transparency=1
59
        end)
60-
local success, fail = pcall(function()
60+
        if v.Name~="Head" and v.Name~="Torso" and v.Name~="HumanoidRootPart" then
61-
   -- Make the fake character invisible
61+
            prt.CanCollide=false
62-
   for _,v in pairs(fakechar:GetDescendants()) do
62+
            prt:GetPropertyChangedSignal("CanCollide"):Connect(function()
63-
       if v:IsA("Part") then
63+
                prt.CanCollide=false
64-
           v.Transparency = 1
64+
            end)
65-
       elseif v:IsA("SpecialMesh") then
65+
        end
66-
           v.MeshId = "rbxassetid://0"
66+
    end
67-
       end
67+
68-
   end
68+
function nocollision(prt)
69
for i,v in pairs(game.Players.LocalPlayer.Character:GetDescendants()) do
70-
   -- Networking
70+
    if v:IsA("BasePart") then
71-
   spawn(function()
71+
        e=Instance.new("NoCollisionConstraint",v)
72-
       while rs.Stepped:wait() and not kill do
72+
        e.Part0 = v
73-
           settings().Physics.AllowSleep = false
73+
        e.Part1 = prt
74-
           
74+
    end
75-
           sethiddenproperty(plr, "MaximumSimulationRadius", math.pow(math.huge,math.huge) * math.huge)
75+
76-
           sethiddenproperty(plr, "SimulationRadius", math.pow(math.huge,math.huge) * math.huge)
76+
77-
       end
77+
for i,v in pairs(char:GetDescendants()) do
78-
   end)
78+
    if v:IsA("BasePart") then
79-
   
79+
        nocollision(v)
80-
   -- Noclipping
80+
    end
81-
   table.insert(connections, rs.Stepped:Connect(function()
81+
82-
       fakechar:FindFirstChild("Head").CanCollide = false
82+
spawn(function()
83-
       fakechar:FindFirstChild("Torso").CanCollide = false
83+
84-
       char.Head.CanCollide = false
84+
local Figure = char.Animate.Parent
85-
       char.Torso.CanCollide = false
85+
local Torso = Figure:WaitForChild("Torso")
86-
   end))
86+
local RightShoulder = Torso:WaitForChild("Right Shoulder")
87-
   table.insert(connections, rs.Heartbeat:Connect(function()
87+
local LeftShoulder = Torso:WaitForChild("Left Shoulder")
88-
       fakechar:FindFirstChild("Head").CanCollide = false
88+
local RightHip = Torso:WaitForChild("Right Hip")
89-
       fakechar:FindFirstChild("Torso").CanCollide = false
89+
local LeftHip = Torso:WaitForChild("Left Hip")
90-
       char.Head.CanCollide = false
90+
local Neck = Torso:WaitForChild("Neck")
91-
       char.Torso.CanCollide = false
91+
local Humanoid = Figure:WaitForChild("Humanoid")
92-
   end))
92+
local pose = "Standing"
93-
   table.insert(connections, rs.RenderStepped:Connect(function()
93+
94-
       fakechar:FindFirstChild("Head").CanCollide = false
94+
local currentAnim = ""
95-
       fakechar:FindFirstChild("Torso").CanCollide = false
95+
local currentAnimInstance = nil
96-
       char.Head.CanCollide = false
96+
local currentAnimTrack = nil
97-
       char.Torso.CanCollide = false
97+
local currentAnimKeyframeHandler = nil
98-
   end))
98+
local currentAnimSpeed = 1.0
99-
   
99+
local animTable = {}
100-
   -- Rigging
100+
local animNames = { 
101-
   char.Torso["Right Shoulder"]:Destroy()
101+
	idle = 	{	
102-
   char.Torso["Left Shoulder"]:Destroy()
102+
				{ id = "http://www.roblox.com/asset/?id=180435571", weight = 9 },
103-
   char.Torso["Right Hip"]:Destroy()
103+
				{ id = "http://www.roblox.com/asset/?id=180435792", weight = 1 }
104-
   char.Torso["Left Hip"]:Destroy()
104+
			},
105-
   char.HumanoidRootPart["RootJoint"]:Destroy()
105+
	walk = 	{ 	
106-
   char.HumanoidRootPart.Anchored = true
106+
				{ id = "http://www.roblox.com/asset/?id=180426354", weight = 10 } 
107-
   char.Humanoid.PlatformStand = true
107+
			}, 
108-
   fakechar["Torso"].Position = char["Torso"].Position
108+
	run = 	{
109
				{ id = "run.xml", weight = 10 } 
110-
   -- Align
110+
			}, 
111-
   for _,v in pairs(char:GetChildren()) do
111+
	jump = 	{
112-
       if v:IsA("Part") and v.Name ~= "Head" then
112+
				{ id = "http://www.roblox.com/asset/?id=125750702", weight = 10 } 
113-
           if v.Name == "Torso" then
113+
			}, 
114-
               Align(char[v.Name], fakechar[v.Name], Vector3.new(0,0.5,0),Vector3.new(0,0,0))
114+
	fall = 	{
115-
           else
115+
				{ id = "http://www.roblox.com/asset/?id=180436148", weight = 10 } 
116-
               Align(char[v.Name], fakechar[v.Name], Vector3.new(0,0,0),Vector3.new(0,0,0))
116+
			}, 
117-
           end
117+
	climb = {
118-
       end
118+
				{ id = "http://www.roblox.com/asset/?id=180436334", weight = 10 } 
119-
   end
119+
			}, 
120
	sit = 	{
121-
if fail then
121+
				{ id = "http://www.roblox.com/asset/?id=178130996", weight = 10 } 
122-
   warn(fail)
122+
			},	
123-
   plr.Character = char
123+
	toolnone = {
124-
   char:BreakJoints()
124+
				{ id = "http://www.roblox.com/asset/?id=182393478", weight = 10 } 
125-
   fakechar:Destroy()
125+
			},
126
	toolslash = {
127-
   kill = true
127+
				{ id = "http://www.roblox.com/asset/?id=129967390", weight = 10 } 
128-
   return
128+
--				{ id = "slash.xml", weight = 10 } 
129
			},
130
	toollunge = {
131-
-- Cleanup
131+
				{ id = "http://www.roblox.com/asset/?id=129967478", weight = 10 } 
132-
fakechar.Humanoid.Died:Connect(function()
132+
			},
133-
   plr.Character = char
133+
	wave = {
134-
   char:BreakJoints()
134+
				{ id = "http://www.roblox.com/asset/?id=128777973", weight = 10 } 
135-
   fakechar:Destroy()
135+
			},
136
	point = {
137-
   kill = true
137+
				{ id = "http://www.roblox.com/asset/?id=128853357", weight = 10 } 
138
			},
139-
   for _,v in pairs(connections) do v:Disconnect() end
139+
	dance1 = {
140
				{ id = "http://www.roblox.com/asset/?id=182435998", weight = 10 }, 
141-
char.Humanoid.Died:Connect(function()
141+
				{ id = "http://www.roblox.com/asset/?id=182491037", weight = 10 }, 
142-
   plr.Character = char
142+
				{ id = "http://www.roblox.com/asset/?id=182491065", weight = 10 } 
143-
   char:BreakJoints()
143+
			},
144-
   fakechar:Destroy()
144+
	dance2 = {
145
				{ id = "http://www.roblox.com/asset/?id=182436842", weight = 10 }, 
146-
   kill = true
146+
				{ id = "http://www.roblox.com/asset/?id=182491248", weight = 10 }, 
147
				{ id = "http://www.roblox.com/asset/?id=182491277", weight = 10 } 
148-
   for _,v in pairs(connections) do v:Disconnect() end
148+
			},
149
	dance3 = {
150
				{ id = "http://www.roblox.com/asset/?id=182436935", weight = 10 }, 
151-
plr.Character = fakechar
151+
				{ id = "http://www.roblox.com/asset/?id=182491368", weight = 10 }, 
152
				{ id = "http://www.roblox.com/asset/?id=182491423", weight = 10 } 
153
			},
154
	laugh = {
155
				{ id = "http://www.roblox.com/asset/?id=129423131", weight = 10 } 
156
			},
157
	cheer = {
158
				{ id = "http://www.roblox.com/asset/?id=129423030", weight = 10 } 
159
			},
160
}
161
local dances = {"dance1", "dance2", "dance3"}
162
163
-- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote
164
local emoteNames = { wave = false, point = false, dance1 = true, dance2 = true, dance3 = true, laugh = false, cheer = false}
165
166
function configureAnimationSet(name, fileList)
167
	if (animTable[name] ~= nil) then
168
		for _, connection in pairs(animTable[name].connections) do
169
			connection:disconnect()
170
		end
171
	end
172
	animTable[name] = {}
173
	animTable[name].count = 0
174
	animTable[name].totalWeight = 0	
175
	animTable[name].connections = {}
176
177
	-- check for config values
178
	local config = char.Animate:FindFirstChild(name)
179
	if (config ~= nil) then
180
--		print("Loading anims " .. name)
181
		table.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))
182
		table.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))
183
		local idx = 1
184
		for _, childPart in pairs(config:GetChildren()) do
185
			if (childPart:IsA("Animation")) then
186
				table.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))
187
				animTable[name][idx] = {}
188
				animTable[name][idx].anim = childPart
189
				local weightObject = childPart:FindFirstChild("Weight")
190
				if (weightObject == nil) then
191
					animTable[name][idx].weight = 1
192
				else
193
					animTable[name][idx].weight = weightObject.Value
194
				end
195
				animTable[name].count = animTable[name].count + 1
196
				animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
197
	--			print(name .. " [" .. idx .. "] " .. animTable[name][idx].anim.AnimationId .. " (" .. animTable[name][idx].weight .. ")")
198
				idx = idx + 1
199
			end
200
		end
201
	end
202
203
	-- fallback to defaults
204
	if (animTable[name].count <= 0) then
205
		for idx, anim in pairs(fileList) do
206
			animTable[name][idx] = {}
207
			animTable[name][idx].anim = Instance.new("Animation")
208
			animTable[name][idx].anim.Name = name
209
			animTable[name][idx].anim.AnimationId = anim.id
210
			animTable[name][idx].weight = anim.weight
211
			animTable[name].count = animTable[name].count + 1
212
			animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
213
--			print(name .. " [" .. idx .. "] " .. anim.id .. " (" .. anim.weight .. ")")
214
		end
215
	end
216
end
217
218
-- Setup animation objects
219
function scriptChildModified(child)
220
	local fileList = animNames[child.Name]
221
	if (fileList ~= nil) then
222
		configureAnimationSet(child.Name, fileList)
223
	end	
224
end
225
226
char.Animate.ChildAdded:connect(scriptChildModified)
227
char.Animate.ChildRemoved:connect(scriptChildModified)
228
229
230
for name, fileList in pairs(animNames) do 
231
	configureAnimationSet(name, fileList)
232
end	
233
234
-- ANIMATION
235
236
-- declarations
237
local toolAnim = "None"
238
local toolAnimTime = 0
239
240
local jumpAnimTime = 0
241
local jumpAnimDuration = 0.3
242
243
local toolTransitionTime = 0.1
244
local fallTransitionTime = 0.3
245
local jumpMaxLimbVelocity = 0.75
246
247
-- functions
248
249
function stopAllAnimations()
250
	local oldAnim = currentAnim
251
252
	-- return to idle if finishing an emote
253
	if (emoteNames[oldAnim] ~= nil and emoteNames[oldAnim] == false) then
254
		oldAnim = "idle"
255
	end
256
257
	currentAnim = ""
258
	currentAnimInstance = nil
259
	if (currentAnimKeyframeHandler ~= nil) then
260
		currentAnimKeyframeHandler:disconnect()
261
	end
262
263
	if (currentAnimTrack ~= nil) then
264
		currentAnimTrack:Stop()
265
		currentAnimTrack:Destroy()
266
		currentAnimTrack = nil
267
	end
268
	return oldAnim
269
end
270
271
function setAnimationSpeed(speed)
272
	if speed ~= currentAnimSpeed then
273
		currentAnimSpeed = speed
274
		currentAnimTrack:AdjustSpeed(currentAnimSpeed)
275
	end
276
end
277
278
function keyFrameReachedFunc(frameName)
279
	if (frameName == "End") then
280
281
		local repeatAnim = currentAnim
282
		-- return to idle if finishing an emote
283
		if (emoteNames[repeatAnim] ~= nil and emoteNames[repeatAnim] == false) then
284
			repeatAnim = "idle"
285
		end
286
		
287
		local animSpeed = currentAnimSpeed
288
		playAnimation(repeatAnim, 0.0, Humanoid)
289
		setAnimationSpeed(animSpeed)
290
	end
291
end
292
293
-- Preload animations
294
function playAnimation(animName, transitionTime, humanoid) 
295
		
296
	local roll = math.random(1, animTable[animName].totalWeight) 
297
	local origRoll = roll
298
	local idx = 1
299
	while (roll > animTable[animName][idx].weight) do
300
		roll = roll - animTable[animName][idx].weight
301
		idx = idx + 1
302
	end
303
--		print(animName .. " " .. idx .. " [" .. origRoll .. "]")
304
	local anim = animTable[animName][idx].anim
305
306
	-- switch animation		
307
	if (anim ~= currentAnimInstance) then
308
		
309
		if (currentAnimTrack ~= nil) then
310
			currentAnimTrack:Stop(transitionTime)
311
			currentAnimTrack:Destroy()
312
		end
313
314
		currentAnimSpeed = 1.0
315
	
316
		-- load it to the humanoid; get AnimationTrack
317
		currentAnimTrack = humanoid:LoadAnimation(anim)
318
		currentAnimTrack.Priority = Enum.AnimationPriority.Core
319
		 
320
		-- play the animation
321
		currentAnimTrack:Play(transitionTime)
322
		currentAnim = animName
323
		currentAnimInstance = anim
324
325
		-- set up keyframe name triggers
326
		if (currentAnimKeyframeHandler ~= nil) then
327
			currentAnimKeyframeHandler:disconnect()
328
		end
329
		currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
330
		
331
	end
332
333
end
334
335
-------------------------------------------------------------------------------------------
336
-------------------------------------------------------------------------------------------
337
338
local toolAnimName = ""
339
local toolAnimTrack = nil
340
local toolAnimInstance = nil
341
local currentToolAnimKeyframeHandler = nil
342
343
function toolKeyFrameReachedFunc(frameName)
344
	if (frameName == "End") then
345
--		print("Keyframe : ".. frameName)	
346
		playToolAnimation(toolAnimName, 0.0, Humanoid)
347
	end
348
end
349
350
351
function playToolAnimation(animName, transitionTime, humanoid, priority)	 
352
		
353
		local roll = math.random(1, animTable[animName].totalWeight) 
354
		local origRoll = roll
355
		local idx = 1
356
		while (roll > animTable[animName][idx].weight) do
357
			roll = roll - animTable[animName][idx].weight
358
			idx = idx + 1
359
		end
360
--		print(animName .. " * " .. idx .. " [" .. origRoll .. "]")
361
		local anim = animTable[animName][idx].anim
362
363
		if (toolAnimInstance ~= anim) then
364
			
365
			if (toolAnimTrack ~= nil) then
366
				toolAnimTrack:Stop()
367
				toolAnimTrack:Destroy()
368
				transitionTime = 0
369
			end
370
					
371
			-- load it to the humanoid; get AnimationTrack
372
			toolAnimTrack = humanoid:LoadAnimation(anim)
373
			if priority then
374
				toolAnimTrack.Priority = priority
375
			end
376
			 
377
			-- play the animation
378
			toolAnimTrack:Play(transitionTime)
379
			toolAnimName = animName
380
			toolAnimInstance = anim
381
382
			currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)
383
		end
384
end
385
386
function stopToolAnimations()
387
	local oldAnim = toolAnimName
388
389
	if (currentToolAnimKeyframeHandler ~= nil) then
390
		currentToolAnimKeyframeHandler:disconnect()
391
	end
392
393
	toolAnimName = ""
394
	toolAnimInstance = nil
395
	if (toolAnimTrack ~= nil) then
396
		toolAnimTrack:Stop()
397
		toolAnimTrack:Destroy()
398
		toolAnimTrack = nil
399
	end
400
401
402
	return oldAnim
403
end
404
405
-------------------------------------------------------------------------------------------
406
-------------------------------------------------------------------------------------------
407
408
409
function onRunning(speed)
410
	if speed > 0.01 then
411
		playAnimation("walk", 0.1, Humanoid)
412
		if currentAnimInstance and currentAnimInstance.AnimationId == "http://www.roblox.com/asset/?id=180426354" then
413
			setAnimationSpeed(speed / 14.5)
414
		end
415
		pose = "Running"
416
	else
417
		if emoteNames[currentAnim] == nil then
418
			playAnimation("idle", 0.1, Humanoid)
419
			pose = "Standing"
420
		end
421
	end
422
end
423
424
function onDied()
425
	pose = "Dead"
426
end
427
428
function onJumping()
429
	playAnimation("jump", 0.1, Humanoid)
430
	jumpAnimTime = jumpAnimDuration
431
	pose = "Jumping"
432
end
433
434
function onClimbing(speed)
435
	playAnimation("climb", 0.1, Humanoid)
436
	setAnimationSpeed(speed / 12.0)
437
	pose = "Climbing"
438
end
439
440
function onGettingUp()
441
	pose = "GettingUp"
442
end
443
444
function onFreeFall()
445
	if (jumpAnimTime <= 0) then
446
		playAnimation("fall", fallTransitionTime, Humanoid)
447
	end
448
	pose = "FreeFall"
449
end
450
451
function onFallingDown()
452
	pose = "FallingDown"
453
end
454
455
function onSeated()
456
	pose = "Seated"
457
end
458
459
function onPlatformStanding()
460
	pose = "PlatformStanding"
461
end
462
463
function onSwimming(speed)
464
	if speed > 0 then
465
		pose = "Running"
466
	else
467
		pose = "Standing"
468
	end
469
end
470
471
function getTool()	
472
	for _, kid in ipairs(Figure:GetChildren()) do
473
		if kid.className == "Tool" then return kid end
474
	end
475
	return nil
476
end
477
478
function getToolAnim(tool)
479
	for _, c in ipairs(tool:GetChildren()) do
480
		if c.Name == "toolanim" and c.className == "StringValue" then
481
			return c
482
		end
483
	end
484
	return nil
485
end
486
487
function animateTool()
488
	
489
	if (toolAnim == "None") then
490
		playToolAnimation("toolnone", toolTransitionTime, Humanoid, Enum.AnimationPriority.Idle)
491
		return
492
	end
493
494
	if (toolAnim == "Slash") then
495
		playToolAnimation("toolslash", 0, Humanoid, Enum.AnimationPriority.Action)
496
		return
497
	end
498
499
	if (toolAnim == "Lunge") then
500
		playToolAnimation("toollunge", 0, Humanoid, Enum.AnimationPriority.Action)
501
		return
502
	end
503
end
504
505
function moveSit()
506
	RightShoulder.MaxVelocity = 0.15
507
	LeftShoulder.MaxVelocity = 0.15
508
	RightShoulder:SetDesiredAngle(3.14 /2)
509
	LeftShoulder:SetDesiredAngle(-3.14 /2)
510
	RightHip:SetDesiredAngle(3.14 /2)
511
	LeftHip:SetDesiredAngle(-3.14 /2)
512
end
513
514
local lastTick = 0
515
516
function move(time)
517
	local amplitude = 1
518
	local frequency = 1
519
  	local deltaTime = time - lastTick
520
  	lastTick = time
521
522
	local climbFudge = 0
523
	local setAngles = false
524
525
  	if (jumpAnimTime > 0) then
526
  		jumpAnimTime = jumpAnimTime - deltaTime
527
  	end
528
529
	if (pose == "FreeFall" and jumpAnimTime <= 0) then
530
		playAnimation("fall", fallTransitionTime, Humanoid)
531
	elseif (pose == "Seated") then
532
		playAnimation("sit", 0.5, Humanoid)
533
		return
534
	elseif (pose == "Running") then
535
		playAnimation("walk", 0.1, Humanoid)
536
	elseif (pose == "Dead" or pose == "GettingUp" or pose == "FallingDown" or pose == "Seated" or pose == "PlatformStanding") then
537
--		print("Wha " .. pose)
538
		stopAllAnimations()
539
		amplitude = 0.1
540
		frequency = 1
541
		setAngles = true
542
	end
543
544
	if (setAngles) then
545
		local desiredAngle = amplitude * math.sin(time * frequency)
546
547
		RightShoulder:SetDesiredAngle(desiredAngle + climbFudge)
548
		LeftShoulder:SetDesiredAngle(desiredAngle - climbFudge)
549
		RightHip:SetDesiredAngle(-desiredAngle)
550
		LeftHip:SetDesiredAngle(-desiredAngle)
551
	end
552
553
	-- Tool Animation handling
554
	local tool = getTool()
555
	if tool and tool:FindFirstChild("Handle") then
556
	
557
		local animStringValueObject = getToolAnim(tool)
558
559
		if animStringValueObject then
560
			toolAnim = animStringValueObject.Value
561
			-- message recieved, delete StringValue
562
			animStringValueObject.Parent = nil
563
			toolAnimTime = time + .3
564
		end
565
566
		if time > toolAnimTime then
567
			toolAnimTime = 0
568
			toolAnim = "None"
569
		end
570
571
		animateTool()		
572
	else
573
		stopToolAnimations()
574
		toolAnim = "None"
575
		toolAnimInstance = nil
576
		toolAnimTime = 0
577
	end
578
end
579
580
-- connect events
581
Humanoid.Died:connect(onDied)
582
Humanoid.Running:connect(onRunning)
583
Humanoid.Jumping:connect(onJumping)
584
Humanoid.Climbing:connect(onClimbing)
585
Humanoid.GettingUp:connect(onGettingUp)
586
Humanoid.FreeFalling:connect(onFreeFall)
587
Humanoid.FallingDown:connect(onFallingDown)
588
Humanoid.Seated:connect(onSeated)
589
Humanoid.PlatformStanding:connect(onPlatformStanding)
590
Humanoid.Swimming:connect(onSwimming)
591
592
-- setup emote chat hook
593
game:GetService("Players").LocalPlayer.Chatted:connect(function(msg)
594
	local emote = ""
595
	if msg == "/e dance" then
596
		emote = dances[math.random(1, #dances)]
597
	elseif (string.sub(msg, 1, 3) == "/e ") then
598
		emote = string.sub(msg, 4)
599
	elseif (string.sub(msg, 1, 7) == "/emote ") then
600
		emote = string.sub(msg, 8)
601
	end
602
	
603
	if (pose == "Standing" and emoteNames[emote] ~= nil) then
604
		playAnimation(emote, 0.1, Humanoid)
605
	end
606
607
end)
608
609
610
-- main program
611
612
-- initialize to idle
613
playAnimation("idle", 0.1, Humanoid)
614
pose = "Standing"
615
616
while Figure.Parent ~= nil do
617
	local _, time = wait(0.1)
618
	move(time)
619
end
620
end)
621
function makeorientacc()
622
AlignOrient = Instance.new("AlignOrientation")
623
AlignOrient.RigidityEnabled = false
624
AlignOrient.MaxTorque = 9e99
625
AlignOrient.MaxAngularVelocity = 9e99
626
AlignOrient.PrimaryAxisOnly = false
627
AlignOrient.ReactionTorqueEnabled = true
628
AlignOrient.Responsiveness = 200
629
return(AlignOrient)
630
end
631
function makealignacc()
632
AlignPos = Instance.new("AlignPosition")
633
AlignPos.RigidityEnabled = false
634
AlignPos.ApplyAtCenterOfMass = true
635
AlignPos.MaxForce = 9e9
636
AlignPos.MaxVelocity = 9e99
637
AlignPos.ReactionForceEnabled = false
638
AlignPos.Responsiveness = 9e99
639
return(AlignPos)
640
end
641
function loopcf(prt1,prt2)
642
    game.RunService.Heartbeat:Connect(function()
643
        prt1.CFrame=prt2.CFrame
644
    end)
645
end
646
function weldm(prt,prt3,offset,tr)
647
prt2=prt3:Clone()
648
prt2.Parent=prt3
649
prt2:BreakJoints()
650
prt2.CanCollide=false
651
prt2.Transparency=1
652
prt2.Anchored=true
653
loopcf(prt2,prt3)
654
prt.Massless = true
655
--prt:BreakJoints()
656
laacc = Instance.new("Attachment",prt)
657
la3acc = Instance.new("Attachment",prt)
658
la2acc = Instance.new("Attachment",prt2)
659
la2acc.CFrame = offset
660
LaAli = makealignacc()
661
LaAli.Attachment0 = laacc
662
LaAli.Attachment1 = la2acc
663
LaAli.Parent = prt
664
LaAli = makeorientacc()
665
LaAli.Attachment0 = la3acc
666
LaAli.Attachment1 = la2acc
667
LaAli.Parent = prt
668
end
669
weldm(la,char["Left Arm"],CFrame.Angles(0,0,0))
670
weldm(ra,char["Right Arm"],CFrame.Angles(0,0,0))
671
weldm(ll,char["Left Leg"],CFrame.Angles(0,0,0))
672
weldm(rl,char["Right Leg"],CFrame.Angles(0,0,0))
673
weldm(t,char["Torso"],CFrame.new(0,0.5,0))
674
if showface == false then
675
char.Head.face.Transparency = 1
676
end
677
char:MoveTo(game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.Position)
678
game.Players.LocalPlayer.Character.Animate.Disabled = true
679
if torso then
680
game.Players.LocalPlayer.Character.HumanoidRootPart.RootJoint:Destroy()
681
else
682
game.Players.LocalPlayer.Character.LowerTorso.Root:Destroy()
683
end
684
Humanoid = game.Players.LocalPlayer.Character.Humanoid
685
char.HumanoidRootPart.Anchored = false
686
game.Workspace.CurrentCamera.CameraSubject = char.Humanoid
687
e = game.RunService.RenderStepped:Connect(function()
688
	local ActiveTracks = Humanoid:GetPlayingAnimationTracks()
689
	for _,v in pairs(ActiveTracks) do
690
    v:Stop()
691
	end
692
    char.Humanoid:Move(game.Players.LocalPlayer.Character.Humanoid.MoveDirection, false)
693
end)
694
game.Players.LocalPlayer.Character.HumanoidRootPart:Destroy()
695
oc=game.Players.LocalPlayer.Character 
696
okasdiasdjkhawdjkaskldjajedlas=Instance.new("ObjectValue",char)
697
okasdiasdjkhawdjkaskldjajedlas.Name="RC"
698
okasdiasdjkhawdjkaskldjajedlas.Value=oc
699
while char.Parent ~= nil do wait() end
700
e:Disconnect()
701
eeeee2:Disconnect()