View difference between Paste ID: pFnrmedR and 2c3Wmihe
SHOW: | | - or go back to the newest paste.
1
function waitForChild(parent, childName)
2
	local child = parent:findFirstChild(childName)
3
	if child then return child end
4
	while true do
5
		child = parent.ChildAdded:wait()
6
		if child.Name==childName then return child end
7
	end
8
end
9
10-
owner = game:GetService("Players").youngmacka123 --<=== change to your name to use
10+
owner = game:GetService("Players").lafur2 --<=== change to your name to use
11
12
local pos = Instance.new("Part",workspace)
13
pos.Anchored = true
14
pos.Position = owner.Character.Torso.Position
15
wait(.1)
16
owner:LoadCharacter()
17
owner.Character.Humanoid.Animator:Destroy()
18
wait(.1)
19
owner.Character.Torso.CFrame = pos.CFrame
20
pos:Destroy()
21
22
char = owner.Character
23
if char:FindFirstChild("Head") then
24
    if char.Head:FindFirstChild("face") ~= nil then
25
        face = char.Head:FindFirstChild("face")
26
        face.Texture = "rbxassetid://3248568733"
27
        face.Parent.Mesh.MeshType = "FileMesh"
28
        face.Parent.Mesh.MeshId = "rbxassetid://1068249467"
29
    end
30
    for i,v in pairs(char:GetChildren()) do
31
        if v.ClassName == "Shirt" or v.ClassName == "Pants" or v.ClassName == "Accessory" or v.ClassName == "CharacterMesh" or v.ClassName == "Shirt Graphic" then
32
            v:Remove()
33
        end
34
        if v.ClassName == "BodyColors" then
35
            v.HeadColor = BrickColor.new("Bright yellow")
36
            v.LeftArmColor = BrickColor.new("Bright yellow")
37
            v.LeftLegColor = BrickColor.new("Br. yellowish green")
38
            v.RightArmColor = BrickColor.new("Bright yellow")
39
            v.RightLegColor = BrickColor.new("Br. yellowish green")
40
            v.TorsoColor = BrickColor.Random()
41
            local Shirt = Instance.new("Shirt",face.Parent.Parent)
42
Shirt.ShirtTemplate = "rbxassetid://1110695025"
43
local Pants = Instance.new("Pants",face.Parent.Parent)
44
Pants.PantsTemplate = "rbxassetid://1110798365"
45
local TShirt = Instance.new("ShirtGraphic",face.Parent.Parent)
46
TShirt.Graphic = "rbxassetid://2650823790"
47
local TorsMesh = Instance.new("CharacterMesh", face.Parent.Parent)
48
TorsMesh.BodyPart = "Torso"
49
TorsMesh.MeshId = 1112228624
50
local RAMesh = Instance.new("CharacterMesh", face.Parent.Parent)
51
RAMesh.BodyPart = "RightArm"
52
RAMesh.MeshId = 1112244824
53
local LAMesh = Instance.new("CharacterMesh", face.Parent.Parent)
54
LAMesh.BodyPart = "LeftArm"
55
LAMesh.MeshId = 1112256772
56
local RLMesh = Instance.new("CharacterMesh", face.Parent.Parent)
57
RLMesh.BodyPart = "RightLeg"
58
RLMesh.MeshId = 1112267576
59
local LLMesh = Instance.new("CharacterMesh", face.Parent.Parent)
60
LLMesh.BodyPart = "LeftLeg"
61
LLMesh.MeshId = 1112275294
62
        end
63
        if v.ClassName == "Part" then
64
            if v.Name == "Head" or v.Name == "FalseHead" then
65
                v.BrickColor = BrickColor.new("Bright yellow")
66
                else
67
                v.BrickColor = BrickColor.new("Bright yellow")
68
            end
69
        end
70
    end
71
end
72
73
local Figure = owner.Character
74
local Torso = waitForChild(Figure, "Torso")
75
local RightShoulder = waitForChild(Torso, "Right Shoulder")
76
local LeftShoulder = waitForChild(Torso, "Left Shoulder")
77
local RightHip = waitForChild(Torso, "Right Hip")
78
local LeftHip = waitForChild(Torso, "Left Hip")
79
local Neck = waitForChild(Torso, "Neck")
80
local Humanoid = waitForChild(Figure, "Humanoid")
81
82
for _,v in pairs (Figure:children()) do
83
    if v:IsA("Part") then v.CanCollide = true end
84
end
85
86
Figure.Head.Running.SoundId = "rbxassetid://174960816"
87
Figure.Head.Running.Volume = 10
88
Figure.Head.Running.PlaybackSpeed = 1
89
Figure.Head.Climbing.SoundId = "rbxassetid://174960816"
90
Figure.Head.Climbing.Volume = 10
91
Figure.Head.Climbing.PlaybackSpeed = 1
92
Figure.Head.Jumping.SoundId = "rbxassetid://400942696"
93
Figure.Head.Jumping.Volume = 10
94
95
function onRunning(speed)
96
	if speed>0 then
97
		pose = "Running"
98
	else
99
		pose = "Standing"
100
	end
101
end
102
103
function onDied()
104
	pose = "Dead"
105
end
106
107
function onJumping()
108
	pose = "Jumping"
109
end
110
111
function onClimbing()
112
	pose = "Climbing"
113
end
114
115
function onGettingUp()
116
	pose = "GettingUp"
117
end
118
119
function onFreeFall()
120
	pose = "FreeFall"
121
end
122
123
function onFallingDown()
124
	pose = "FallingDown"
125
end
126
127
function onSeated()
128
	pose = "Seated"
129
end
130
131
function onPlatformStanding()
132
	pose = "PlatformStanding"
133
end
134
135
function moveJump()
136
	RightShoulder.MaxVelocity = 0.5
137
	LeftShoulder.MaxVelocity = 0.5
138
	RightShoulder.DesiredAngle = 3.14
139
	LeftShoulder.DesiredAngle = -3.14 
140
	RightHip.DesiredAngle = 0
141
	LeftHip.DesiredAngle = 0
142
end
143
144
145
-- same as jump for now
146
147
function moveFreeFall()
148
	RightShoulder.MaxVelocity = 0.5
149
	LeftShoulder.MaxVelocity = 0.5
150
	RightShoulder.DesiredAngle = 3.14
151
	LeftShoulder.DesiredAngle = -3.14 
152
	RightHip.DesiredAngle = 0
153
	LeftHip.DesiredAngle = 0	
154
end
155
156
function moveSit()
157
	RightShoulder.MaxVelocity = 0.15
158
	LeftShoulder.MaxVelocity = 0.15
159
	RightShoulder.DesiredAngle = 3.14/2
160
	LeftShoulder.DesiredAngle = -3.14/2
161
	RightHip.DesiredAngle = 3.14/2
162
	LeftHip.DesiredAngle = -3.14/2
163
end
164
165
function getTool()	
166
	for _, kid in ipairs(Figure:GetChildren()) do
167
		if kid.className == "Tool" then return kid end
168
	end
169
	return nil
170
end
171
172
function getToolAnim(tool)
173
	for _, c in ipairs(tool:GetChildren()) do
174
		if c.Name == "toolanim" and c.className == "StringValue" then
175
			return c
176
		end
177
	end
178
	return nil
179
end
180
181
function animateTool()
182
	
183
	if (toolAnim == "None") then
184
		RightShoulderdDesiredAngle = 1.57
185
		return
186
	end
187
188
	if (toolAnim == "Slash") then
189
		RightShoulder.MaxVelocity = 0.5
190
		RightShoulder.DesiredAngle = 0
191
		return
192
	end
193
194
	if (toolAnim == "Lunge") then
195
		RightShoulder.MaxVelocity = 0.5
196
		LeftShoulder.MaxVelocity = 0.5
197
		RightHip.MaxVelocity = 0.5
198
		LeftHip.MaxVelocity = 0.5
199
		RightShoulder.DesiredAngle = 1.57
200
		LeftShoulder.DesiredAngle = 0 
201
		RightHip.DesiredAngle = 1.57
202
		LeftHip.DesiredAngle = 1.0		
203
		return
204
	end
205
end
206
207
function move(time)
208
	local amplitude
209
	local frequency
210
  
211
	if (pose == "Jumping") then
212
		moveJump()
213
		return
214
	end
215
216
	if (pose == "FreeFall") then
217
		moveFreeFall()
218
		return
219
	end
220
 
221
	if (pose == "Seated") then
222
		moveSit()
223
		return
224
	end
225
226
	local climbFudge = 0
227
	
228
	if (pose == "Running") then
229
		RightShoulder.MaxVelocity = 0.15
230
		LeftShoulder.MaxVelocity = 0.15
231
		amplitude = 1
232
		frequency = 9
233
	elseif (pose == "Climbing") then
234
		RightShoulder.MaxVelocity = 0.5 
235
		LeftShoulder.MaxVelocity = 0.5
236
		amplitude = 1
237
		frequency = 9
238
		climbFudge = 3.14
239
	else
240
		amplitude = 0.1
241
		frequency = 1
242
	end
243
244
	desiredAngle = amplitude * math.sin(time*frequency)
245
	
246
	RightShoulder.DesiredAngle = desiredAngle + climbFudge
247
	LeftShoulder.DesiredAngle = desiredAngle - climbFudge 
248
	RightHip.DesiredAngle = -desiredAngle
249
	LeftHip.DesiredAngle = -desiredAngle 
250
251
	local tool = getTool()
252
253
	if tool then
254
	
255
		animStringValueObject = getToolAnim(tool)
256
257
		if animStringValueObject then
258
			toolAnim = animStringValueObject.Value
259
			-- message recieved, delete StringValue
260
			animStringValueObject.Parent = nil
261
			toolAnimTime = time + .3
262
		end
263
264
		if time > toolAnimTime then
265
			toolAnimTime = 0
266
			toolAnim = "None"
267
		end
268
269
		animateTool()
270
271
		
272
	else
273
		toolAnim = "None"
274
		toolAnimTime = 0
275
	end
276
end
277
278
279
-- connect events
280
281
Humanoid.Died:connect(onDied)
282
Humanoid.Running:connect(onRunning)
283
Humanoid.Jumping:connect(onJumping)
284
Humanoid.Climbing:connect(onClimbing)
285
Humanoid.GettingUp:connect(onGettingUp)
286
Humanoid.FreeFalling:connect(onFreeFall)
287
Humanoid.FallingDown:connect(onFallingDown)
288
Humanoid.Seated:connect(onSeated)
289
Humanoid.PlatformStanding:connect(onPlatformStanding)
290
291
-- main program
292
293
local runService = game:service("RunService");
294
295
while Figure.Parent~=nil do
296
	local _, time = wait(0.1)
297
	move(time)
298
end