Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
- local Player,Mouse,mouse,UserInputService,ContextActionService = owner
- do
- script.Parent = Player.Character
- --RemoteEvent for communicating
- local Event = Instance.new("RemoteEvent")
- Event.Name = "UserInput_Event"
- --Fake event to make stuff like Mouse.KeyDown work
- local function fakeEvent()
- local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
- t.connect = t.Connect
- return t
- end
- --Creating fake input objects with fake variables
- local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
- local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
- local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
- CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
- end}
- --Merged 2 functions into one by checking amount of arguments
- CAS.UnbindAction = CAS.BindAction
- --This function will trigger the events that have been :Connect()'ed
- local function te(self,ev,...)
- local t = m[ev]
- if t and t._fakeEvent and t.Function then
- t.Function(...)
- end
- end
- m.TrigEvent = te
- UIS.TrigEvent = te
- Event.OnServerEvent:Connect(function(plr,io)
- if plr~=Player then return end
- if io.isMouse then
- m.Target = io.Target
- m.Hit = io.Hit
- else
- local b = io.UserInputState == Enum.UserInputState.Begin
- if io.UserInputType == Enum.UserInputType.MouseButton1 then
- return m:TrigEvent(b and "Button1Down" or "Button1Up")
- end
- for _,t in pairs(CAS.Actions) do
- for _,k in pairs(t.Keys) do
- if k==io.KeyCode then
- t.Function(t.Name,io.UserInputState,io)
- end
- end
- end
- m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
- UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
- end
- end)
- Event.Parent = NLS([==[
- local Player = game:GetService("Players").LocalPlayer
- local Event = script:WaitForChild("UserInput_Event")
- local UIS = game:GetService("UserInputService")
- local input = function(io,a)
- if a then return end
- --Since InputObject is a client-side instance, we create and pass table instead
- Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
- end
- UIS.InputBegan:Connect(input)
- UIS.InputEnded:Connect(input)
- local Mouse = Player:GetMouse()
- local h,t
- --Give the server mouse data 30 times every second, but only if the values changed
- --If player is not moving their mouse, client won't fire events
- while wait(1/30) do
- if h~=Mouse.Hit or t~=Mouse.Target then
- h,t=Mouse.Hit,Mouse.Target
- Event:FireServer({isMouse=true,Target=t,Hit=h})
- end
- end]==],Player.Character)
- Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
- end
- local Handle = Instance.new("Part")
- local Mesh = Instance.new("SpecialMesh")
- local Part = Instance.new("Part")
- local Attachment = Instance.new("Attachment")
- local WeldConstraint = Instance.new("WeldConstraint")
- local Part_1 = Instance.new("Part")
- local Attachment_1 = Instance.new("Attachment")
- local WeldConstraint_1 = Instance.new("WeldConstraint")
- local Trail = Instance.new("Trail")
- -- SETTING PROPERTIES
- Handle.Anchored = false
- Handle.BottomSurface = Enum.SurfaceType.Smooth
- Handle.CFrame = CFrame.new(-19.933,1.4,74.334,1,0,-0.001,0,1,0.001,0.001,-0.001,1)
- Handle.Color = Color3.new(0.067,0.067,0.067)
- Handle.Material = Enum.Material.ForceField
- Handle.Size = Vector3.new(0.2,2.8,1)
- Handle.TopSurface = Enum.SurfaceType.Smooth
- Handle.Name = "Handle"
- Handle.Parent = owner.Character
- Mesh.MeshType = Enum.MeshType.FileMesh
- Mesh.MeshId = "http://www.roblox.com/asset/?id=121944778 "
- Mesh.Parent = Handle
- Part.BottomSurface = Enum.SurfaceType.Smooth
- Part.CFrame = CFrame.new(-19.932,0.055,74.333,1,0,-0.001,0,1,0.001,0.001,-0.001,1)
- Part.Size = Vector3.new(0.1,0.1,0.1)
- Part.TopSurface = Enum.SurfaceType.Smooth
- Part.Transparency = 1
- Part.Parent = Handle
- Attachment.Parent = Part
- WeldConstraint.Part0 = Part
- WeldConstraint.Part1 = Handle
- WeldConstraint.Parent = Part
- Part_1.BottomSurface = Enum.SurfaceType.Smooth
- Part_1.CFrame = CFrame.new(-19.932,2.733,74.332,1,0,-0.001,0,1,0.001,0.001,-0.001,1)
- Part_1.Size = Vector3.new(0.1,0.1,0.1)
- Part_1.TopSurface = Enum.SurfaceType.Smooth
- Part_1.Transparency = 1
- Part_1.Parent = Handle
- Attachment_1.Parent = Part_1
- WeldConstraint_1.Part0 = Part_1
- WeldConstraint_1.Part1 = Handle
- WeldConstraint_1.Parent = Part_1
- Trail.Attachment0 = Attachment
- Trail.Attachment1 = Attachment_1
- Trail.Color = ColorSequence.new(Color3.new(0,0,0))
- Trail.LightInfluence = 1
- Trail.Transparency = NumberSequence.new({NumberSequenceKeypoint.new(0,0,0),NumberSequenceKeypoint.new(1,1,0),NumberSequenceKeypoint.new(1,0,0)})
- Trail.Parent = Handle
- function wbtwe(Part0, Part1, C0)
- local weld = Instance.new("Weld", Part0)
- weld.Part0 = Part0
- weld.Part1 = Part1
- weld.C0 = Part1.CFrame:inverse() *Part1.CFrame *C0
- return weld
- end
- idle = 5
- walk = 5
- deb = false
- animt = true
- slash = false
- mode = 1
- hrw = wbtwe(owner.Character.Torso, owner.Character.HumanoidRootPart, CFrame.new(0, 0, 0) *CFrame.Angles(0, 0, 0))
- law = wbtwe(owner.Character["Left Arm"], owner.Character.Torso, CFrame.new(1.3, 1, 1) *CFrame.Angles(5.3, 25, 0))
- raw = wbtwe(owner.Character["Right Arm"], owner.Character.Torso, CFrame.new(-1.5, 0, 0) *CFrame.Angles(0, 0, -0.05))
- llw = wbtwe(owner.Character["Left Leg"], owner.Character.HumanoidRootPart, CFrame.new(0.45, 2.1, 0) *CFrame.Angles(0, 25, 0.05))
- rlw = wbtwe(owner.Character["Right Leg"], owner.Character.HumanoidRootPart, CFrame.new(-0.4, 2.1, 0) *CFrame.Angles(0, 0, -0.05))
- hw = wbtwe(owner.Character.Head, owner.Character.Torso, CFrame.new(0, -1.5, 0) *CFrame.Angles(0, 0, 0))
- knw = wbtwe(Handle, owner.Character["Left Arm"], CFrame.new(-0.1, -0.3, 0.8) *CFrame.Angles(1, 0, 0))
- local stab = Instance.new("Sound", Handle)
- stab.SoundId = "rbxassetid://3533899133"
- stab.Volume = 3
- local song = Instance.new("Sound", owner.Character.Head)
- song.SoundId = "rbxassetid://1382488262"
- song.PlaybackSpeed = 0.2
- song.TimePosition = 3
- song.Looped = true
- song.Volume = 2
- song:Play()
- Instance.new("EchoSoundEffect", song)
- anim = coroutine.wrap(function()
- deb = true
- animt = false
- owner.Character.Humanoid.WalkSpeed = 2
- owner.Character.Humanoid.JumpPower = 0
- local laugh = Instance.new("Sound", owner.Character.Head)
- laugh.SoundId = "rbxassetid://1238240145"
- laugh.Volume = 3
- laugh:Play()
- for i = 1,105 do
- game:GetService("RunService").Stepped:wait()
- idle = idle +0.5
- hrw.C0 = hrw.C0:lerp(owner.Character.HumanoidRootPart.CFrame:inverse() *owner.Character.HumanoidRootPart.CFrame *CFrame.new(0, math.sin(idle) *0.1, 0), 0.4)
- hw.C0 = hw.C0:lerp(owner.Character.Torso.CFrame:inverse() *owner.Character.Torso.CFrame *CFrame.new(0, -1.5, 0.3) *CFrame.Angles(-0.3, 0, 0), 0.4)
- law.C0 = law.C0:lerp(owner.Character.Torso.CFrame:inverse() *owner.Character.Torso.CFrame *CFrame.new(1.3, 1, 1) *CFrame.Angles(5.3, 25, 0), 0.4)
- raw.C0 = raw.C0:lerp(owner.Character.Torso.CFrame:inverse() *owner.Character.Torso.CFrame *CFrame.new(-1.5, 0, 0) *CFrame.Angles(0, 0, -0.05), 0.4)
- llw.C0 = llw.C0:lerp(owner.Character.Torso.CFrame:inverse() *owner.Character.Torso.CFrame *CFrame.new(0.45, 2.1, 0) *CFrame.Angles(0, 25, 0.05), 0.4)
- rlw.C0 = rlw.C0:lerp(owner.Character.Torso.CFrame:inverse() *owner.Character.Torso.CFrame *CFrame.new(-0.4, 2.1, 0) *CFrame.Angles(0, 0, -0.05), 0.4)
- end
- deb = false
- animt = true
- owner.Character.Humanoid.WalkSpeed = 16
- owner.Character.Humanoid.JumpPower = 50
- while game:GetService("RunService").Stepped:wait() do
- if animt == true then
- hw.C0 = hw.C0:lerp(owner.Character.Torso.CFrame:inverse() *owner.Character.Torso.CFrame *CFrame.new(0, -1.5, 0) *CFrame.Angles(math.rad(math.random(-3,3)), math.rad(math.random(-3,3)), math.rad(math.random(-3,3))), 1)
- if owner.Character.HumanoidRootPart.Velocity.Magnitude < 1 then
- idle = idle +0.1
- hrw.C0 = hrw.C0:lerp(owner.Character.HumanoidRootPart.CFrame:inverse() *owner.Character.HumanoidRootPart.CFrame *CFrame.new(0, math.sin(idle) *0.2, 0), 0.4)
- law.C0 = law.C0:lerp(owner.Character.Torso.CFrame:inverse() *owner.Character.Torso.CFrame *CFrame.new(1.3, 1, 1) *CFrame.Angles(5.3, 25, 0), 0.4)
- raw.C0 = raw.C0:lerp(owner.Character.Torso.CFrame:inverse() *owner.Character.Torso.CFrame *CFrame.new(-1.5, 0, 0) *CFrame.Angles(0, 0, -0.05), 0.4)
- llw.C0 = llw.C0:lerp(owner.Character.Torso.CFrame:inverse() *owner.Character.Torso.CFrame *CFrame.new(0.45, 2.1, 0) *CFrame.Angles(0, 25, 0.05), 0.4)
- rlw.C0 = rlw.C0:lerp(owner.Character.Torso.CFrame:inverse() *owner.Character.Torso.CFrame *CFrame.new(-0.4, 2.1, 0) *CFrame.Angles(0, 0, -0.05), 0.4)
- end
- if owner.Character.HumanoidRootPart.Velocity.Magnitude > 1 then
- walk = walk + 0.2
- hrw.C0 = hrw.C0:lerp(owner.Character.HumanoidRootPart.CFrame:inverse() *owner.Character.HumanoidRootPart.CFrame *CFrame.new(0, math.sin(walk) *0.2, 0), 0.4)
- law.C0 = law.C0:lerp(owner.Character.Torso.CFrame:inverse() *owner.Character.Torso.CFrame *CFrame.new(1.3, 1, 1) *CFrame.Angles(5.3, 25, 0), 0.4)
- raw.C0 = raw.C0:lerp(owner.Character.Torso.CFrame:inverse() *owner.Character.Torso.CFrame *CFrame.new(-1.5, 0,math.cos(walk) *-0.2) *CFrame.Angles(math.cos(walk) *0.2, 0, -0.05), 0.4)
- llw.C0 = llw.C0:lerp(owner.Character.Torso.CFrame:inverse() *owner.Character.Torso.CFrame *CFrame.new(0.45, 2.1, math.cos(walk) *0.2) *CFrame.Angles(math.cos(walk) *-0.2, 25, 0.05), 0.4)
- rlw.C0 = rlw.C0:lerp(owner.Character.Torso.CFrame:inverse() *owner.Character.Torso.CFrame *CFrame.new(-0.4, 2.1, math.cos(walk) *-0.2) *CFrame.Angles(math.cos(walk) *0.2, 0, -0.05), 0.4)
- end
- end
- end
- end)anim()
- mouse.KeyDown:connect(function(k)
- if k == "t" then
- if deb == false then
- deb = true
- animt = false
- owner.Character.Humanoid.WalkSpeed = 2
- owner.Character.Humanoid.JumpPower = 0
- local laugh = Instance.new("Sound", owner.Character.Head)
- laugh.SoundId = "rbxassetid://1238240145"
- laugh.Volume = 3
- laugh:Play()
- for i = 1,105 do
- game:GetService("RunService").Stepped:wait()
- idle = idle +0.5
- hrw.C0 = hrw.C0:lerp(owner.Character.HumanoidRootPart.CFrame:inverse() *owner.Character.HumanoidRootPart.CFrame *CFrame.new(0, math.sin(idle) *0.1, 0), 0.4)
- hw.C0 = hw.C0:lerp(owner.Character.Torso.CFrame:inverse() *owner.Character.Torso.CFrame *CFrame.new(0, -1.5, 0.3) *CFrame.Angles(-0.3, 0, 0), 0.4)
- law.C0 = law.C0:lerp(owner.Character.Torso.CFrame:inverse() *owner.Character.Torso.CFrame *CFrame.new(1.3, 1, 1) *CFrame.Angles(5.3, 25, 0), 0.4)
- raw.C0 = raw.C0:lerp(owner.Character.Torso.CFrame:inverse() *owner.Character.Torso.CFrame *CFrame.new(-1.5, 0, 0) *CFrame.Angles(0, 0, -0.05), 0.4)
- llw.C0 = llw.C0:lerp(owner.Character.Torso.CFrame:inverse() *owner.Character.Torso.CFrame *CFrame.new(0.45, 2.1, 0) *CFrame.Angles(0, 25, 0.05), 0.4)
- rlw.C0 = rlw.C0:lerp(owner.Character.Torso.CFrame:inverse() *owner.Character.Torso.CFrame *CFrame.new(-0.4, 2.1, 0) *CFrame.Angles(0, 0, -0.05), 0.4)
- end
- deb = false
- animt = true
- owner.Character.Humanoid.WalkSpeed = 16
- owner.Character.Humanoid.JumpPower = 50
- end
- end
- end)
- mouse.Button1Down:connect(function()
- if deb == false then
- deb = true
- animt = false
- slash = true
- owner.Character.Humanoid.WalkSpeed = 2
- owner.Character.Humanoid.JumpPower = 0
- local swing = Instance.new("Sound", owner.Character.Head)
- swing.SoundId = "rbxassetid://1086616651"
- swing.Volume = 3
- swing:Play()
- for i = 1,25 do
- game:GetService("RunService").Stepped:wait()
- hrw.C0 = hrw.C0:lerp(owner.Character.HumanoidRootPart.CFrame:inverse() *owner.Character.HumanoidRootPart.CFrame *CFrame.new(0, 0, 0) *CFrame.Angles(0, 0.4, 0), 0.4)
- hw.C0 = hw.C0:lerp(owner.Character.Torso.CFrame:inverse() *owner.Character.Torso.CFrame *CFrame.new(0, -1.5, 0) *CFrame.Angles(0, 0, 0), 0.4)
- law.C0 = law.C0:lerp(owner.Character.Torso.CFrame:inverse() *owner.Character.Torso.CFrame *CFrame.new(1.5, 0, -1) *CFrame.Angles(5.3, 26, -5.3), 0.4)
- raw.C0 = raw.C0:lerp(owner.Character.Torso.CFrame:inverse() *owner.Character.Torso.CFrame *CFrame.new(-1.5, 0, 0) *CFrame.Angles(0, 0, -0.05), 0.4)
- llw.C0 = llw.C0:lerp(owner.Character.Torso.CFrame:inverse() *owner.Character.Torso.CFrame *CFrame.new(0.45, 2.1, 0) *CFrame.Angles(0, 25, 0.05), 0.4)
- rlw.C0 = rlw.C0:lerp(owner.Character.Torso.CFrame:inverse() *owner.Character.Torso.CFrame *CFrame.new(-0.4, 2.1, 0) *CFrame.Angles(0, 0, -0.05), 0.4)
- end
- slash = false
- deb = false
- animt = true
- owner.Character.Humanoid.WalkSpeed = 16
- owner.Character.Humanoid.JumpPower = 50
- end
- end)
- Handle.Touched:connect(function(p)
- if slash == true then
- if p.Parent:FindFirstChild("Torso") then
- if p.Parent:FindFirstChildOfClass("Humanoid").Health > 0 then
- p.Parent:FindFirstChildOfClass("Humanoid").Health = 0
- stab:Play()
- Character=p.Parent
- local leftarm = Character:FindFirstChild("Left Arm")
- local leftleg = Character:FindFirstChild("Left Leg")
- local rightleg = Character:FindFirstChild("Right Leg")
- local rightarm = Character:FindFirstChild("Right Arm")
- local torso = Character:FindFirstChild("Torso")
- local head = Character:FindFirstChild("Head")
- local root = Character:FindFirstChild("HumanoidRootPart")
- local HeadA = Instance.new("Attachment")
- HeadA.Name = "HeadA"
- HeadA.Parent = head
- HeadA.Position = Vector3.new(0, -0.5, 0)
- HeadA.Rotation = Vector3.new(0, 0, -0)
- HeadA.Axis = Vector3.new(1, -0, -0)
- HeadA.SecondaryAxis = Vector3.new(0, 1, 0)
- local LeftArmA = Instance.new("Attachment")
- LeftArmA.Name = "LeftArmA"
- LeftArmA.Parent = leftarm
- LeftArmA.Position = Vector3.new(0.4, 0.8, 0)
- LeftArmA.Rotation = Vector3.new(-180, 0, 90)
- LeftArmA.Axis = Vector3.new(0, -1, -0)
- LeftArmA.SecondaryAxis = Vector3.new(-1, 0, 0)
- local LeftLegA = Instance.new("Attachment")
- LeftLegA.Name = "LeftLegA"
- LeftLegA.Parent = leftleg
- LeftLegA.Position = Vector3.new(0, 1, 0)
- LeftLegA.Rotation = Vector3.new(90, -90, 0)
- LeftLegA.Axis = Vector3.new(0, -1, -0)
- LeftLegA.SecondaryAxis = Vector3.new(0, -0, 1)
- local RightArmA = Instance.new("Attachment")
- RightArmA.Name = "RightArmA"
- RightArmA.Parent = rightarm
- RightArmA.Position = Vector3.new(-0.4, 0.8, 0)--Vector3.new(0, 1, 0)
- RightArmA.Rotation = Vector3.new(-180, 0, 90)--Vector3.new(90, -90, 0)
- RightArmA.Axis = Vector3.new(0, -1, -0)--Vector3.new(0, -1, -0)
- RightArmA.SecondaryAxis = Vector3.new(0, 1, 0)--Vector3.new(0, -0, 1)
- local RightLegA = Instance.new("Attachment")
- RightLegA.Name = "RightLegA"
- RightLegA.Parent = rightleg
- RightLegA.Position = Vector3.new(0, 1, 0) --Vector3.new(-0.4, 0.8, 0)
- RightLegA.Rotation = Vector3.new(90, -90, 0)--Vector3.new(-180, 0, 90)
- RightLegA.Axis = Vector3.new(0, -1, -0)--Vector3.new(0, -1, -0)
- RightLegA.SecondaryAxis = Vector3.new(0, -0, 1)--Vector3.new(0, 1, 0)
- local TorsoA = Instance.new("Attachment")
- TorsoA.Name = "TorsoA"
- TorsoA.Parent = torso
- TorsoA.Position = Vector3.new(0.5, -1.1, 0)
- TorsoA.Rotation = Vector3.new(90, -90, 0)
- TorsoA.Axis = Vector3.new(0, -1, -0)
- TorsoA.SecondaryAxis = Vector3.new(0, -0, 1)
- local TorsoA1 = Instance.new("Attachment")
- TorsoA1.Name = "TorsoA1"
- TorsoA1.Parent = torso
- TorsoA1.Position = Vector3.new(-0.5, -1.1, 0)
- TorsoA1.Rotation = Vector3.new(90, -90, 0)
- TorsoA1.Axis = Vector3.new(0, -1, -0)
- TorsoA1.SecondaryAxis = Vector3.new(0, -0, 1)
- local TorsoA2 = Instance.new("Attachment")
- TorsoA2.Name = "TorsoA2"
- TorsoA2.Parent = torso
- TorsoA2.Position = Vector3.new(-1, 0.8, 0)
- TorsoA2.Rotation = Vector3.new(0, 0, -180)
- TorsoA2.Axis = Vector3.new(-1, -0, 0)
- TorsoA2.SecondaryAxis = Vector3.new(0, -1, 0)
- local TorsoA3 = Instance.new("Attachment")
- TorsoA3.Name = "TorsoA3"
- TorsoA3.Parent = torso
- TorsoA3.Position = Vector3.new(1, 0.8, 0)
- TorsoA3.Rotation = Vector3.new(-180, 0, 0)
- TorsoA3.Axis = Vector3.new(1, -0, 0)
- TorsoA3.SecondaryAxis = Vector3.new(-0, -1, -0)
- local TorsoA4 = Instance.new("Attachment")
- TorsoA4.Name = "TorsoA4"
- TorsoA4.Parent = torso
- TorsoA4.Position = Vector3.new(0, 1, 0)
- TorsoA4.Rotation = Vector3.new(0, 0, -0)
- TorsoA4.Axis = Vector3.new(1, -0, 0)
- TorsoA4.SecondaryAxis = Vector3.new(0, 1, 0)
- local TorsoA5 = Instance.new("Attachment")
- TorsoA5.Name = "TorsoA5"
- TorsoA5.Parent = torso
- TorsoA5.Position = Vector3.new(0, 0, 0)
- TorsoA5.Rotation = Vector3.new(0, 90, 0)
- TorsoA5.Axis = Vector3.new(0, 0, -1)
- TorsoA5.SecondaryAxis = Vector3.new(0, 1, 0)
- local TorsoA6 = Instance.new("Attachment")
- TorsoA6.Name = "TorsoA6"
- TorsoA6.Parent = torso
- TorsoA6.Position = Vector3.new(0, 1, 0)
- TorsoA5.Rotation = Vector3.new(0, 0, 0)
- --TorsoA6.Axis = Vector3.new(0, 0, -1)
- --TorsoA6.SecondaryAxis = Vector3.new(0, 1, 0)
- local rootA = Instance.new("Attachment")
- rootA.Name= "rootA"
- rootA.Parent = root
- rootA.Position = Vector3.new(0, 0, 0)
- rootA.Rotation = Vector3.new(0, 90, 0)
- rootA.Axis = Vector3.new(0, 0, -1)
- rootA.SecondaryAxis = Vector3.new(0, 1, 0)
- local LAT = Instance.new("BallSocketConstraint")
- LAT.Parent = leftarm
- LAT.Attachment0 = LeftArmA
- LAT.Attachment1 = TorsoA2
- LAT.Enabled = true
- local RAT = Instance.new("BallSocketConstraint")
- RAT.Parent = rightarm
- RAT.Attachment0 = RightArmA
- RAT.Attachment1 = TorsoA3
- RAT.Enabled = true
- local TLL = Instance.new("BallSocketConstraint")
- TLL.Parent = torso
- TLL.Attachment0 = TorsoA1
- TLL.Attachment1 = LeftLegA
- TLL.Enabled = true
- local TRL = Instance.new("BallSocketConstraint")
- TRL.Parent = torso
- TRL.Attachment0 = TorsoA
- TRL.Attachment1 = RightLegA
- TRL.Enabled = true
- local RTA = Instance.new("BallSocketConstraint")
- RTA.Parent = root
- RTA.Attachment0 = rootA
- RTA.Attachment1 = TorsoA5
- RTA.Enabled = true
- local Neck = Instance.new("BallSocketConstraint")
- Neck.Parent = torso
- Neck.Attachment0 = TorsoA6
- Neck.Attachment1 = HeadA
- Neck.Enabled = true
- function getAttachment0(attachmentName)
- for _,child in next,Character:GetChildren() do
- local attachment = child:FindFirstChild(attachmentName)
- if attachment then
- return attachment
- end
- end
- end
- for _,child in next,Character:GetChildren() do
- if child:IsA("Accoutrement") then
- --Loop through all parts instead of only checking for one to be forwards-compatible in the event
- --ROBLOX implements multi-part accessories
- for _,part in next,child:GetChildren() do
- if part:IsA("BasePart") then
- local attachment1 = part:FindFirstChildOfClass("Attachment")
- local attachment0 = getAttachment0(attachment1.Name)
- if attachment0 and attachment1 then
- --Shouldn't use constraints for this, but have to because of a ROBLOX idiosyncrasy where
- --joints connecting a character are perpetually deleted while the character is dead
- local constraint = Instance.new("HingeConstraint")
- constraint.Attachment0 = attachment0
- constraint.Attachment1 = attachment1
- constraint.LimitsEnabled = true
- constraint.UpperAngle = 0 --Simulate weld by making it difficult for constraint to move
- constraint.LowerAngle = 0
- constraint.Parent = Character
- end
- end
- end
- end
- end
- end
- end
- if p.Parent:FindFirstChild("UpperTorso") then
- if p.Parent:FindFirstChildOfClass("Humanoid").Health > 0 then
- p.Parent:FindFirstChildOfClass("Humanoid").Health = 0
- stab:Play()
- character=p.Parent
- function recurse(root,callback,i)
- i= i or 0
- for _,v in pairs(root:GetChildren()) do
- i = i + 1
- callback(i,v)
- if #v:GetChildren() > 0 then
- i = recurse(v,callback,i)
- end
- end
- return i
- end
- function ragdollJoint(part0, part1, attachmentName, className, properties)
- attachmentName = attachmentName.."RigAttachment"
- local constraint = Instance.new(className.."Constraint")
- constraint.Attachment0 = part0:FindFirstChild(attachmentName)
- constraint.Attachment1 = part1:FindFirstChild(attachmentName)
- constraint.Name = "RagdollConstraint"..part1.Name
- for _,propertyData in next,properties or {} do
- constraint[propertyData[1]] = propertyData[2]
- end
- constraint.Parent = character
- end
- function getAttachment0(attachmentName)
- for _,child in next,character:GetChildren() do
- local attachment = child:FindFirstChild(attachmentName)
- if attachment then
- return attachment
- end
- end
- end
- --character:WaitForChild("Humanoid").Died:connect(function()
- local camera = workspace.CurrentCamera
- if camera.CameraSubject == character.Humanoid then--If developer isn't controlling camera
- camera.CameraSubject = character.UpperTorso
- end
- --Make it so ragdoll can't collide with invisible HRP, but don't let HRP fall through map and be destroyed in process
- character.HumanoidRootPart.Anchored = true
- character.HumanoidRootPart.CanCollide = false
- --Helps to fix constraint spasms
- recurse(character, function(_,v)
- if v:IsA("Attachment") then
- v.Axis = Vector3.new(0, 1, 0)
- v.SecondaryAxis = Vector3.new(0, 0, 1)
- v.Rotation = Vector3.new(0, 0, 0)
- end
- end)
- --Re-attach hats
- for _,child in next,character:GetChildren() do
- if child:IsA("Accoutrement") then
- --Loop through all parts instead of only checking for one to be forwards-compatible in the event
- --ROBLOX implements multi-part accessories
- for _,part in next,child:GetChildren() do
- if part:IsA("BasePart") then
- local attachment1 = part:FindFirstChildOfClass("Attachment")
- local attachment0 = getAttachment0(attachment1.Name)
- if attachment0 and attachment1 then
- --Shouldn't use constraints for this, but have to because of a ROBLOX idiosyncrasy where
- --joints connecting a character are perpetually deleted while the character is dead
- local constraint = Instance.new("HingeConstraint")
- constraint.Attachment0 = attachment0
- constraint.Attachment1 = attachment1
- constraint.LimitsEnabled = true
- constraint.UpperAngle = 0 --Simulate weld by making it difficult for constraint to move
- constraint.LowerAngle = 0
- constraint.Parent = character
- end
- end
- end
- end
- end
- ragdollJoint(character.LowerTorso, character.UpperTorso, "Waist", "BallSocket", {
- {"LimitsEnabled",true};
- {"UpperAngle",5};
- })
- --[
- ragdollJoint(character.UpperTorso, character.Head, "Neck", "BallSocket", {
- {"LimitsEnabled",true};
- {"UpperAngle",15};
- })--]]
- local handProperties = {
- {"LimitsEnabled", true};
- {"UpperAngle",0};
- {"LowerAngle",0};
- }
- ragdollJoint(character.LeftLowerArm, character.LeftHand, "LeftWrist", "Hinge", handProperties)
- ragdollJoint(character.RightLowerArm, character.RightHand, "RightWrist", "Hinge", handProperties)
- local shinProperties = {
- {"LimitsEnabled", true};
- {"UpperAngle", 0};
- {"LowerAngle", -75};
- }
- ragdollJoint(character.LeftUpperLeg, character.LeftLowerLeg, "LeftKnee", "Hinge", shinProperties)
- ragdollJoint(character.RightUpperLeg, character.RightLowerLeg, "RightKnee", "Hinge", shinProperties)
- local footProperties = {
- {"LimitsEnabled", true};
- {"UpperAngle", 15};
- {"LowerAngle", -45};
- }
- ragdollJoint(character.LeftLowerLeg, character.LeftFoot, "LeftAnkle", "Hinge", footProperties)
- ragdollJoint(character.RightLowerLeg, character.RightFoot, "RightAnkle", "Hinge", footProperties)
- --TODO fix ability for socket to turn backwards whenn ConeConstraints are shipped
- ragdollJoint(character.UpperTorso, character.LeftUpperArm, "LeftShoulder", "BallSocket")
- ragdollJoint(character.LeftUpperArm, character.LeftLowerArm, "LeftElbow", "BallSocket")
- ragdollJoint(character.UpperTorso, character.RightUpperArm, "RightShoulder", "BallSocket")
- ragdollJoint(character.RightUpperArm, character.RightLowerArm, "RightElbow", "BallSocket")
- ragdollJoint(character.LowerTorso, character.LeftUpperLeg, "LeftHip", "BallSocket")
- ragdollJoint(character.LowerTorso, character.RightUpperLeg, "RightHip", "BallSocket")
- --end)
- end
- end
- end
- end)
Add Comment
Please, Sign In to add comment