· 8 years ago · Aug 03, 2018, 12:46 PM
1if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
2local Player,game,owner = owner,game
3local RealPlayer = Player
4do
5 print("FE Compatibility code by Mokiros")
6 local rp = RealPlayer
7 script.Parent = rp.Character
8
9 --RemoteEvent for communicating
10 local Event = Instance.new("RemoteEvent")
11 Event.Name = "UserInput_Event"
12
13 --Fake event to make stuff like Mouse.KeyDown work
14 local function fakeEvent()
15 local t = {_fakeEvent=true,Functions={},Connect=function(self,f)table.insert(self.Functions,f) end}
16 t.connect = t.Connect
17 return t
18 end
19
20 --Creating fake input objects with fake variables
21 local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
22 local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
23 local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
24 CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
25 end}
26 --Merged 2 functions into one by checking amount of arguments
27 CAS.UnbindAction = CAS.BindAction
28
29 --This function will trigger the events that have been :Connect()'ed
30 local function te(self,ev,...)
31 local t = m[ev]
32 if t and t._fakeEvent then
33 for _,f in pairs(t.Functions) do
34 f(...)
35 end
36 end
37 end
38 m.TrigEvent = te
39 UIS.TrigEvent = te
40
41 Event.OnServerEvent:Connect(function(plr,io)
42 if plr~=rp then return end
43 m.Target = io.Target
44 m.Hit = io.Hit
45 if not io.isMouse then
46 local b = io.UserInputState == Enum.UserInputState.Begin
47 if io.UserInputType == Enum.UserInputType.MouseButton1 then
48 return m:TrigEvent(b and "Button1Down" or "Button1Up")
49 end
50 for _,t in pairs(CAS.Actions) do
51 for _,k in pairs(t.Keys) do
52 if k==io.KeyCode then
53 t.Function(t.Name,io.UserInputState,io)
54 end
55 end
56 end
57 m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
58 UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
59 end
60 end)
61 Event.Parent = NLS([==[
62 local Player = game:GetService("Players").LocalPlayer
63 local Event = script:WaitForChild("UserInput_Event")
64
65 local Mouse = Player:GetMouse()
66 local UIS = game:GetService("UserInputService")
67 local input = function(io,a)
68 if a then return end
69 --Since InputObject is a client-side instance, we create and pass table instead
70 Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
71 end
72 UIS.InputBegan:Connect(input)
73 UIS.InputEnded:Connect(input)
74
75 local h,t
76 --Give the server mouse data 30 times every second, but only if the values changed
77 --If player is not moving their mouse, client won't fire events
78 while wait(1/30) do
79 if h~=Mouse.Hit or t~=Mouse.Target then
80 h,t=Mouse.Hit,Mouse.Target
81 Event:FireServer({isMouse=true,Target=t,Hit=h})
82 end
83 end]==],Player.Character)
84
85 ----Sandboxed game object that allows the usage of client-side methods and services
86 --Real game object
87 local _rg = game
88
89 --Metatable for fake service
90 local fsmt = {
91 __index = function(self,k)
92 local s = rawget(self,"_RealService")
93 if s then return s[k] end
94 end,
95 __newindex = function(self,k,v)
96 local s = rawget(self,"_RealService")
97 if s then s[k]=v end
98 end,
99 __call = function(self,...)
100 local s = rawget(self,"_RealService")
101 if s then return s(...) end
102 end
103 }
104 local function FakeService(t,RealService)
105 t._RealService = typeof(RealService)=="string" and _rg:GetService(RealService) or RealService
106 return setmetatable(t,fsmt)
107 end
108
109 --Fake game object
110 local g = {
111 GetService = function(self,s)
112 return self[s]
113 end,
114 Players = FakeService({
115 LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
116 },"Players"),
117 UserInputService = FakeService(UIS,"UserInputService"),
118 ContextActionService = FakeService(CAS,"ContextActionService"),
119 }
120 rawset(g.Players,"localPlayer",g.Players.LocalPlayer)
121 g.service = g.GetService
122
123 g.RunService = FakeService({
124 RenderStepped = _rg:GetService("RunService").Heartbeat,
125 BindToRenderStep = function(self,name,_,fun)
126 self._btrs[name] = self.Heartbeat:Connect(fun)
127 end,
128 UnbindFromRenderStep = function(self,name)
129 self._btrs[name]:Disconnect()
130 end,
131 },"RunService")
132
133 setmetatable(g,{
134 __index=function(self,s)
135 return _rg:GetService(s) or typeof(_rg[s])=="function"
136 and function(_,...)return _rg[s](_rg,...)end or _rg[s]
137 end,
138 __newindex = fsmt.__newindex,
139 __call = fsmt.__call
140 })
141 --Changing owner to fake player object to support owner:GetMouse()
142 game,owner = g,g.Players.LocalPlayer
143end
144
145function sandbox(var,func)
146 local env = getfenv(func)
147 local newenv = setmetatable({},{
148 __index = function(self,k)
149 if k=="script" then
150 return var
151 else
152 return env[k]
153 end
154 end,
155 })
156 setfenv(func,newenv)
157 return func
158end
159cors = {}
160mas = Instance.new("Model",game:GetService("Lighting"))
161Tool0 = Instance.new("Tool")
162BoolValue1 = Instance.new("BoolValue")
163BoolValue2 = Instance.new("BoolValue")
164BoolValue3 = Instance.new("BoolValue")
165BoolValue4 = Instance.new("BoolValue")
166Script5 = Instance.new("Script")
167LocalScript6 = Instance.new("LocalScript")
168LocalScript7 = Instance.new("LocalScript")
169LocalScript8 = Instance.new("LocalScript")
170Part9 = Instance.new("Part")
171Sound10 = Instance.new("Sound")
172Sound11 = Instance.new("Sound")
173Sound12 = Instance.new("Sound")
174SpecialMesh13 = Instance.new("SpecialMesh")
175Animation14 = Instance.new("Animation")
176Animation15 = Instance.new("Animation")
177Animation16 = Instance.new("Animation")
178Animation17 = Instance.new("Animation")
179Animation18 = Instance.new("Animation")
180Script19 = Instance.new("Script")
181Script20 = Instance.new("Script")
182Tool0.Name = "Knife"
183Tool0.Parent = mas
184Tool0.TextureId = "http://www.roblox.com/asset?id=155344898"
185Tool0.GripPos = Vector3.new(0, -1, -0.100000001)
186BoolValue1.Name = "PlayDownStab"
187BoolValue1.Parent = Tool0
188BoolValue2.Name = "PlayStabPunch"
189BoolValue2.Parent = Tool0
190BoolValue3.Name = "PlayThrow"
191BoolValue3.Parent = Tool0
192BoolValue4.Name = "PlayThrowCharge"
193BoolValue4.Parent = Tool0
194Script5.Name = "SoundScript"
195Script5.Parent = Tool0
196table.insert(cors,sandbox(Script5,function()
197-- Waits for the child of the specified parent
198local function WaitForChild(parent, childName)
199 while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
200 return parent[childName]
201end
202
203
204local Tool = script.Parent
205local Handle = WaitForChild(Tool, 'Handle')
206local Debounce = false
207
208local TouchConnection
209
210
211function OnTouched(hit)
212 local humanoid = hit.Parent:findFirstChild('Humanoid')
213 if Debounce == false then
214 Debounce = true
215 if humanoid then
216
217 else
218 Handle.Ting:Play()
219 end
220 end
221 wait(0.5)
222 Debounce = false
223end
224
225
226Tool.Equipped:connect(function()
227 TouchConnection = Handle.Touched:connect(OnTouched)
228end)
229
230Tool.Unequipped:connect(function()
231 if TouchConnection then
232 TouchConnection:disconnect()
233 TouchConnection = nil
234 end
235end)
236
237end))
238LocalScript6.Name = "AnimationScript"
239LocalScript6.Parent = Tool0
240table.insert(cors,sandbox(LocalScript6,function()
241-- Waits for the child of the specified parent
242local function WaitForChild(parent, childName)
243 while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
244 return parent[childName]
245end
246
247local Tool = script.Parent
248
249local downStabAnim
250local stabPunchAnim
251local throwAnim
252local throwChargeAnim
253
254local MyHumanoid
255
256-- This table will make sure that when we stop an animation it is
257-- because it is the only animation of it running
258local PlayCountTable = {}
259
260
261local function PlayAnimation(animation, valueToCheck, animationLength)
262 if valueToCheck and valueToCheck.Value then
263 if MyHumanoid then
264 animation:Play()
265 if PlayCountTable[animation] then
266 PlayCountTable[animation] = PlayCountTable[animation] + 1
267 end
268 -- wait the duration of the animation
269 if animationLength then
270 wait(animationLength)
271 if PlayCountTable[animation] then
272 PlayCountTable[animation] = PlayCountTable[animation] - 1
273 if PlayCountTable[animation] == 0 then
274 animation:Stop()
275 end
276 end
277 end
278 end
279 end
280end
281
282function OnEquipped()
283 MyHumanoid = Tool.Parent:FindFirstChild('Humanoid')
284 downStabAnim = MyHumanoid:LoadAnimation(WaitForChild(Tool, 'DownStab'))
285 PlayCountTable[downStabAnim] = 0
286 stabPunchAnim = MyHumanoid:LoadAnimation(WaitForChild(Tool, 'StabPunch'))
287 PlayCountTable[stabPunchAnim] = 0
288 throwAnim = MyHumanoid:LoadAnimation(WaitForChild(Tool, 'Throw'))
289 PlayCountTable[throwAnim] = 0
290 throwChargeAnim = MyHumanoid:LoadAnimation(WaitForChild(Tool, 'ThrowCharge'))
291 PlayCountTable[throwChargeAnim] = 0
292
293
294 local playStabPunch = WaitForChild(Tool, 'PlayStabPunch')
295 local playDownStab = WaitForChild(Tool, 'PlayDownStab')
296 local playThrow = WaitForChild(Tool, 'PlayThrow')
297 local playThrowCharge = WaitForChild(Tool, 'PlayThrowCharge')
298
299 playStabPunch.Changed:connect(function() PlayAnimation(stabPunchAnim, playStabPunch, 1.0) end)
300 playDownStab.Changed:connect(function() PlayAnimation(downStabAnim, playDownStab, 1.0) end)
301 playThrow.Changed:connect(function() PlayAnimation(throwAnim, playThrow, 1.5) end)
302 playThrowCharge.Changed:connect(function(value)
303 if value then
304 PlayAnimation(throwChargeAnim, playThrowCharge, 1.0)
305 else
306 throwChargeAnim:Stop()
307 end
308 end)
309end
310
311function OnUnequipped()
312 if downStabAnim then
313 downStabAnim:Stop()
314 downStabAnim = nil
315 end
316 if stabPunchAnim then
317 stabPunchAnim:Stop()
318 stabPunchAnim = nil
319 end
320 if throwAnim then
321 throwAnim:Stop()
322 throwAnim = nil
323 end
324 if throwChargeAnim then
325 throwChargeAnim:Stop()
326 throwChargeAnim = nil
327 end
328 PlayCountTable = {}
329end
330
331Tool.Equipped:connect(OnEquipped)
332Tool.Unequipped:connect(OnUnequipped)
333
334
335end))
336LocalScript7.Name = "BladeGui"
337LocalScript7.Parent = Tool0
338table.insert(cors,sandbox(LocalScript7,function()
339local Tool = script.Parent
340
341function OnButton1Down(mouse)
342 if Tool.Enabled then
343 mouse.Icon = 'http://www.roblox.com/asset/?id=54019936'
344 else
345 mouse.Icon = 'http://www.roblox.com/asset/?id=54019936'
346 end
347 while not Tool.Enabled do
348 Tool.Changed:wait()
349 end
350 if Tool.Enabled then
351 mouse.Icon = 'http://www.roblox.com/asset/?id=54019936'
352 end
353end
354
355function OnEquipped(mouse)
356 if mouse == nil then
357 print("Mouse not found")
358 return
359 end
360
361 mouse.Icon = 'http://www.roblox.com/asset/?id=54019936'
362 mouse.Button1Down:connect(function() OnButton1Down(mouse) end)
363end
364
365
366Tool.Equipped:connect(OnEquipped)
367
368end))
369LocalScript8.Name = "KnifeScript"
370LocalScript8.Parent = Tool0
371table.insert(cors,sandbox(LocalScript8,function()
372--------------------- TEMPLATE BLADE WEAPON ---------------------------
373-- Waits for the child of the specified parent
374local function WaitForChild(parent, childName)
375 while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
376 return parent[childName]
377end
378
379
380local SLASH_DAMAGE = 20
381local DOWNSTAB_DAMAGE = 35
382local THROWING_DAMAGE = 40
383local HOLD_TO_THROW_TIME = 0.38
384
385
386local Damage = 20
387
388local MyHumanoid = nil
389local MyTorso = nil
390local MyCharacter = nil
391local MyPlayer = nil
392
393local Tool = script.Parent
394local Handle = WaitForChild(Tool, 'Handle')
395
396local BlowConnection
397local Button1DownConnection
398local Button1UpConnection
399
400local PlayStabPunch
401local PlayDownStab
402local PlayThrow
403local PlayThrowCharge
404
405local IconUrl = Tool.TextureId -- URL to the weapon knife icon asset
406
407local DebrisService = game:GetService('Debris')
408local PlayersService = game:GetService('Players')
409
410local SlashSound
411
412local HitPlayers = {}
413
414local LeftButtonDownTime = nil
415
416local Attacking = false
417
418function Blow(hit)
419 if Attacking then
420 BlowDamage(hit, Damage)
421 end
422end
423
424function BlowDamage(hit, damage)
425 local humanoid = hit.Parent:FindFirstChild('Humanoid')
426 local player = PlayersService:GetPlayerFromCharacter(hit.Parent)
427 if humanoid ~= nil and MyHumanoid ~= nil and humanoid ~= MyHumanoid then
428 if not MyPlayer.Neutral then
429 -- Ignore teammates hit
430 if player and player ~= MyPlayer and player.TeamColor == MyPlayer.TeamColor then
431 return
432 end
433 end
434 -- final check, make sure weapon is in-hand
435 local rightArm = MyCharacter:FindFirstChild('Right Arm')
436 if (rightArm ~= nil) then
437 -- Check if the weld exists between the hand and the weapon
438 local joint = rightArm:FindFirstChild('RightGrip')
439 if (joint ~= nil and (joint.Part0 == Handle or joint.Part1 == Handle)) then
440 -- Make sure you only hit them once per swing
441 TagHumanoid(humanoid, MyPlayer)
442 print("Sending " .. damage)
443
444 local checksound = humanoid.Parent:findFirstChild("Sound")
445 if checksound == nil then
446 local givesound = script.Parent.Sound:clone()
447 givesound.Parent = humanoid.Parent
448 givesound.Disabled = false
449 else
450 checksound:remove()
451 local givesound = script.Parent.Sound:clone()
452 givesound.Parent = humanoid.Parent
453 givesound.Disabled = false
454 end
455 wait()
456 humanoid:TakeDamage(humanoid.MaxHealth)
457 if humanoid.Health == math.huge or humanoid.MaxHealth == math.huge then
458 humanoid.Parent:BreakJoints()
459 end
460 end
461 end
462 end
463end
464
465function TagHumanoid(humanoid, player)
466 -- Add more tags here to customize what tags are available.
467 while humanoid:FindFirstChild('creator') do
468 humanoid:FindFirstChild('creator'):Destroy()
469 end
470
471 local creatorTag = Instance.new('ObjectValue')
472 creatorTag.Value = player
473 creatorTag.Name = 'creator'
474 creatorTag.Parent = humanoid
475 DebrisService:AddItem(creatorTag, 1.5)
476
477 local weaponIconTag = Instance.new('StringValue')
478 weaponIconTag.Value = IconUrl
479 weaponIconTag.Name = 'icon'
480 weaponIconTag.Parent = creatorTag
481 DebrisService:AddItem(weaponIconTag, 1.5)
482end
483
484function HardAttack()
485 Damage = SLASH_DAMAGE
486 HitSound:play()
487 if PlayStabPunch then
488 PlayStabPunch.Value = true
489 wait(1.0)
490 PlayStabPunch.Value = false
491 end
492end
493
494function NormalAttack()
495 Damage = DOWNSTAB_DAMAGE
496 KnifeDown()
497 HitSound:play()
498 if PlayDownStab then
499 PlayDownStab.Value = true
500 wait(1.0)
501 PlayDownStab.Value = false
502 end
503 KnifeUp()
504end
505
506function ThrowAttack()
507 KnifeOut()
508 if PlayThrow then
509 PlayThrow.Value = true
510 wait()
511 if not Handle then return end
512 local throwingHandle = Handle:Clone()
513 DebrisService:AddItem(throwingHandle, 5)
514 throwingHandle.Parent = game.Workspace
515 if MyCharacter and MyHumanoid then
516 throwingHandle.Velocity = (MyHumanoid.TargetPoint - throwingHandle.CFrame.p).unit * 100
517 -- set the orientation to the direction it is being thrown in
518 throwingHandle.CFrame = CFrame.new(throwingHandle.CFrame.p, throwingHandle.CFrame.p + throwingHandle.Velocity) * CFrame.Angles(0, 0, math.rad(-90))
519 local floatingForce = Instance.new('BodyForce', throwingHandle)
520 floatingForce.force = Vector3.new(0, 196.2 * throwingHandle:GetMass() * 0.98, 0)
521 local spin = Instance.new('BodyAngularVelocity', throwingHandle)
522 spin.angularvelocity = throwingHandle.CFrame:vectorToWorldSpace(Vector3.new(0, -400, 0))
523 end
524 Handle.Transparency = 1
525 -- Wait so that the knife has left the thrower's general area
526 wait()
527 if throwingHandle then
528 local Throwevent = script.Parent.ThrowHandleHitWeld:Clone()
529 Throwevent.Parent = throwingHandle
530 Throwevent.Disabled = false
531 local touchedConn = throwingHandle.Touched:connect(function(hit) print("hit throw") BlowDamage(hit, THROWING_DAMAGE) end)
532 end
533 -- must check if it still exists since we waited
534 if throwingHandle then
535 throwingHandle.CanCollide = true
536 end
537 wait(0.6)
538 if Handle and PlayThrow then
539 Handle.Transparency = 0
540 PlayThrow.Value = false
541 end
542 end
543 KnifeUp()
544end
545
546function KnifeUp()
547 Tool.GripForward = Vector3.new(0,0,-1)
548 Tool.GripRight = Vector3.new(1,0,0)
549 Tool.GripUp = Vector3.new(0,1,0)
550end
551
552function KnifeDown()
553 Tool.GripForward = Vector3.new(0,0,-1)
554 Tool.GripRight = Vector3.new(1,0,0)
555 Tool.GripUp = Vector3.new(0,-1,0)
556end
557
558function KnifeOut()
559 Tool.GripForward = Vector3.new(0,0,-1)
560 Tool.GripRight = Vector3.new(1,0,0)
561 Tool.GripUp = Vector3.new(0,1,0)
562end
563
564Tool.Enabled = true
565
566function OnLeftButtonDown()
567 LeftButtonDownTime = time()
568 if PlayThrowCharge then
569 PlayThrowCharge.Value = true
570 end
571end
572
573function OnLeftButtonUp()
574 if not Tool.Enabled then return end
575 -- Reset the list of hit players every time we start a new attack
576 HitPlayers = {}
577 if PlayThrowCharge then
578 PlayThrowCharge.Value = false
579 end
580 if Tool.Enabled and MyHumanoid and MyHumanoid.Health > 0 then
581 Tool.Enabled = false
582 local currTime = time()
583 if LeftButtonDownTime and currTime - LeftButtonDownTime > HOLD_TO_THROW_TIME and
584 currTime - LeftButtonDownTime < 1.15 then
585 ThrowAttack()
586 else
587 Attacking = true
588 if math.random(1, 2) == 1 then
589 HardAttack()
590 else
591 NormalAttack()
592 end
593 Attacking = false
594 end
595 Tool.Enabled = true
596 end
597end
598
599function OnEquipped(mouse)
600 PlayStabPunch = WaitForChild(Tool, 'PlayStabPunch')
601 PlayDownStab = WaitForChild(Tool, 'PlayDownStab')
602 PlayThrow = WaitForChild(Tool, 'PlayThrow')
603 PlayThrowCharge = WaitForChild(Tool, 'PlayThrowCharge')
604 SlashSound = WaitForChild(Handle, 'Swoosh1')
605 HitSound = WaitForChild(Handle, 'Ting')
606 SlashSound:play()
607 BlowConnection = Handle.Touched:connect(Blow)
608 MyCharacter = Tool.Parent
609 MyTorso = MyCharacter:FindFirstChild('Torso')
610 MyHumanoid = MyCharacter:FindFirstChild('Humanoid')
611 MyPlayer = PlayersService.LocalPlayer
612 if mouse then
613 Button1DownConnection = mouse.Button1Down:connect(OnLeftButtonDown)
614 Button1UpConnection = mouse.Button1Up:connect(OnLeftButtonUp)
615 end
616 KnifeUp()
617end
618
619function OnUnequipped()
620 -- Unequip logic here
621 if BlowConnection then
622 BlowConnection:disconnect()
623 BlowConnection = nil
624 end
625 if Button1DownConnection then
626 Button1DownConnection:disconnect()
627 Button1DownConnection = nil
628 end
629 if Button1UpConnection then
630 Button1UpConnection:disconnect()
631 Button1UpConnection = nil
632 end
633 MyHumanoid = nil
634end
635
636
637Tool.Equipped:connect(OnEquipped)
638Tool.Unequipped:connect(OnUnequipped)
639
640end))
641Part9.Name = "Handle"
642Part9.Parent = Tool0
643Part9.Material = Enum.Material.DiamondPlate
644Part9.BrickColor = BrickColor.new("Really black")
645Part9.Reflectance = 0.0099999997764826
646Part9.Rotation = Vector3.new(-180, 0, -180)
647Part9.Elasticity = 0
648Part9.FormFactor = Enum.FormFactor.Custom
649Part9.Size = Vector3.new(0.400000006, 3, 0.699999988)
650Part9.CFrame = CFrame.new(0, 17.2999992, 22, -1, 0, 0, 0, 1, 0, 0, 0, -1)
651Part9.BottomSurface = Enum.SurfaceType.Smooth
652Part9.TopSurface = Enum.SurfaceType.Smooth
653Part9.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
654Part9.Position = Vector3.new(0, 17.2999992, 22)
655Part9.Orientation = Vector3.new(0, 180, 0)
656Part9.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
657Sound10.Name = "Swoosh"
658Sound10.Parent = Part9
659Sound10.SoundId = "http://www.roblox.com/asset?id=153647529"
660Sound10.Volume = 1
661Sound10.PlayOnRemove = true
662Sound11.Name = "Swoosh1"
663Sound11.Parent = Part9
664Sound11.SoundId = "http://www.roblox.com/asset?id=153647514"
665Sound11.Volume = 1
666Sound11.PlayOnRemove = true
667Sound12.Name = "Ting"
668Sound12.Parent = Part9
669Sound12.SoundId = "http://www.roblox.com/asset?id=153647529"
670Sound12.Volume = 0.20000000298023
671SpecialMesh13.Parent = Part9
672SpecialMesh13.MeshId = "http://www.roblox.com/asset/?id=121944778 "
673SpecialMesh13.TextureId = "http://www.roblox.com/asset/?id=121944805 "
674SpecialMesh13.MeshType = Enum.MeshType.FileMesh
675Animation14.Name = "DownStab"
676Animation14.Parent = Tool0
677Animation14.AnimationId = "http://www.roblox.com/Asset?ID=89133529"
678Animation15.Name = "KnifeIdle"
679Animation15.Parent = Tool0
680Animation16.Name = "StabPunch"
681Animation16.Parent = Tool0
682Animation16.AnimationId = "http://www.roblox.com/Asset?ID=89134792"
683Animation17.Name = "Throw"
684Animation17.Parent = Tool0
685Animation17.AnimationId = "http://www.roblox.com/Asset?ID=89147993"
686Animation18.Name = "ThrowCharge"
687Animation18.Parent = Tool0
688Animation18.AnimationId = "http://www.roblox.com/Asset?ID=93103762"
689Script19.Name = "ThrowHandleHitWeld"
690Script19.Parent = Tool0
691Script19.Disabled = true
692table.insert(cors,sandbox(Script19,function()
693arrow = script.Parent
694
695
696local HitSound = Instance.new("Sound")
697HitSound.SoundId = "http://www.roblox.com/asset?id=153647563"
698HitSound.Parent = arrow
699HitSound.Volume = .5
700
701
702function stick(hit)
703
704 local AV = arrow:findFirstChild("BodyForce")
705 local FO = arrow:findFirstChild("BodyAngularVelocity")
706
707 if AV ~= nil then AV:remove() end
708 if FO ~= nil then FO:remove() end
709
710 -- joint myself to the thing i hit
711
712 local weld = Instance.new("Weld")
713
714 weld.Name = "PieWeld"
715 weld.Part0 = arrow
716 weld.Part1 = hit
717
718 local backupweld = Instance.new("Weld")
719
720 backupweld.Name = "PieWeldBackup"
721 backupweld.Part0 = arrow
722 backupweld.Part1 = hit
723
724 -- correction term to account for average skew between physics update and heartbeat
725 local HitPos = arrow.Position --+ (-arrow.Velocity * (1/60)) --+ (arrow.CFrame.lookVector * .5)
726
727 local CJ = CFrame.new(HitPos)
728 local C0 = arrow.CFrame:inverse() *CJ
729 local C1 = hit.CFrame:inverse() * CJ
730
731 weld.C0 = C0
732 weld.C1 = C1
733
734 weld.Parent = arrow
735
736 backupweld.C0 = C0
737 backupweld.C1 = C1
738
739 backupweld.Parent = arrow
740
741end
742
743
744function onTouched(hit)
745
746 connection:disconnect()
747
748 stick(hit)
749 HitSound:Play()
750
751
752end
753
754
755
756connection = arrow.Touched:connect(onTouched)
757
758
759
760wait(2)
761
762if (arrow:FindFirstChild("PieWeld") ~= nil) then
763 arrow.PieWeld:Remove()
764end
765
766wait(8)
767
768arrow.Parent = nil
769end))
770Script20.Name = "Sound"
771Script20.Parent = Tool0
772Script20.Disabled = true
773table.insert(cors,sandbox(Script20,function()
774-- For knife
775
776function waitForChild(parent, childName)
777 local child = parent:findFirstChild(childName)
778 if child then return child end
779 while true do
780 child = parent.ChildAdded:wait()
781 if child.Name==childName then return child end
782 end
783end
784
785function newSound(id)
786 local sound = Instance.new("Sound")
787 sound.SoundId = id
788 sound.archivable = false
789 sound.Parent = script.Parent.Head
790 return sound
791end
792
793-- declarations
794
795local sDied = newSound("http://www.roblox.com/asset?id=146594640")
796local sFallingDown = newSound("rbxasset://sounds/splat.wav")
797local sFreeFalling = newSound("rbxasset://sounds/swoosh.wav")
798local sGettingUp = newSound("rbxasset://sounds/hit.wav")
799local sJumping = newSound("rbxasset://sounds/button.wav")
800local sRunning = newSound("rbxasset://sounds/bfsl-minifigfoots1.mp3")
801sRunning.Looped = true
802
803local Figure = script.Parent
804local Head = waitForChild(Figure, "Head")
805local Humanoid = waitForChild(Figure, "Humanoid")
806
807-- functions
808
809function onDied()
810 sDied:Play()
811end
812
813function onState(state, sound)
814 if state then
815 sound:Play()
816 else
817 sound:Pause()
818 end
819end
820
821function onRunning(speed)
822 if speed>0.01 then
823 sRunning:Play()
824 else
825 sRunning:Pause()
826 end
827end
828
829-- connect up
830
831Humanoid.Died:connect(onDied)
832Humanoid.Running:connect(onRunning)
833Humanoid.Jumping:connect(function(state) onState(state, sJumping) end)
834Humanoid.GettingUp:connect(function(state) onState(state, sGettingUp) end)
835Humanoid.FreeFalling:connect(function(state) onState(state, sFreeFalling) end)
836Humanoid.FallingDown:connect(function(state) onState(state, sFallingDown) end)
837
838end))
839for i,v in pairs(mas:GetChildren()) do
840 v.Parent = game:GetService("Players").LocalPlayer.Backpack
841 pcall(function() v:MakeJoints() end)
842end
843mas:Destroy()
844for i,v in pairs(cors) do
845 spawn(function()
846 pcall(v)
847 end)
848end