Advertisement
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,game,owner = owner,game
- local RealPlayer = Player
- do local RealPlayer=RealPlayer;script.Parent=RealPlayer.Character;local a=function(b)b[1].f[b[2]]=nil end;local c={__index={disconnect=a,Disconnect=a}}local d={__index={Connect=function(b,e)local f=tostring(math.random(0,10000))while b.f[f]do f=tostring(math.random(0,10000))end;b.f[f]=e;return setmetatable({b,f},c)end}}d.__index.connect=d.__index.Connect;local function g()return setmetatable({f={}},d)end;local h={Hit=CFrame.new(),KeyUp=g(),KeyDown=g(),Button1Up=g(),Button1Down=g(),Button2Up=g(),Button2Down=g()}h.keyUp=h.KeyUp;h.keyDown=h.KeyDown;local i={InputBegan=g(),InputEnded=g()}local CAS={Actions={},BindAction=function(self,j,k,l,...)CAS.Actions[j]=k and{Name=j,Function=k,Keys={...}}or nil end}CAS.UnbindAction=CAS.BindAction;local function m(self,n,...)for o,e in pairs(self[n].f)do e(...)end end;h.T=m;i.T=m;local p=Instance.new("RemoteEvent")p.Name="UserInput_Event"p.OnServerEvent:Connect(function(q,r)if q~=RealPlayer then return end;h.Target=r.e;h.Hit=r.d;if not r.f then local s=r.c==Enum.UserInputState.Begin;if r.b==Enum.UserInputType.MouseButton1 then return h:T(s and"Button1Down"or"Button1Up")end;if r.b==Enum.UserInputType.MouseButton2 then return h:T(s and"Button2Down"or"Button2Up")end;for o,t in pairs(CAS.Actions)do for o,u in pairs(t.Keys)do if u==r.a then t.Function(t.Name,r.c,r)end end end;h:T(s and"KeyDown"or"KeyUp",r.a.Name:lower())i:T(s and"InputBegan"or"InputEnded",r,false)end end)p.Parent=NLS([==[local a=script:WaitForChild("UserInput_Event")local b=owner:GetMouse()local c=game:GetService("UserInputService")local d=function(e,f)if f then return end;a:FireServer({a=e.KeyCode,b=e.UserInputType,c=e.UserInputState,d=b.Hit,e=b.Target})end;c.InputBegan:Connect(d)c.InputEnded:Connect(d)local g,h;local i=game:GetService("RunService").Heartbeat;while true do if g~=b.Hit or h~=b.Target then g,h=b.Hit,b.Target;a:FireServer({f=1,Target=h,d=g})end;for j=1,2 do i:Wait()end end]==],script)local v=game;local w={__index=function(self,u)local x=rawget(self,"_RealService")if x then return typeof(x[u])=="function"and function(o,...)return x[u](x,...)end or x[u]end end,__newindex=function(self,u,y)local x=rawget(self,"_RealService")if x then x[u]=y end end}local function z(t,A)t._RealService=typeof(A)=="string"and v:GetService(A)or A;return setmetatable(t,w)end;local B={GetService=function(self,x)return rawget(self,x)or v:GetService(x)end,Players=z({LocalPlayer=z({GetMouse=function(self)return h end},Player)},"Players"),UserInputService=z(i,"UserInputService"),ContextActionService=z(CAS,"ContextActionService"),RunService=z({_btrs={},RenderStepped=v:GetService("RunService").Heartbeat,BindToRenderStep=function(self,j,o,k)self._btrs[j]=self.Heartbeat:Connect(k)end,UnbindFromRenderStep=function(self,j)self._btrs[j]:Disconnect()end},"RunService")}rawset(B.Players,"localPlayer",B.Players.LocalPlayer)B.service=B.GetService;z(B,game)game,owner=B,B.Players.LocalPlayer end
- Player = game:GetService("Players").LocalPlayer
- Char = Player.Character
- local Sound = Instance.new("Sound", Char.Torso)
- Sound.SoundId = "http://www.roblox.com/asset/?id=1907454616"
- Sound.Volume = 1
- Sound.TimePosition = 12.919996252995535002
- Sound.Looped = true
- Sound:Play()
- function recurse(root,callback,i)
- coroutine.resume(coroutine.create(function()
- 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
- end))
- return i
- end
- function MakeAth(AthParent,AthName,AthPosX,AthPosY,AthPosZ,AthRot,AthAX,SecondaryAxis)
- coroutine.resume(coroutine.create(function()
- local ATH = Instance.new("Attachment",AthParent)
- ATH.Position = Vector3.new(AthPosX,AthPosY,AthPosZ)
- ATH.Name = AthName
- if AthRot ~= nil then
- ATH.Rotation = AthRot end
- if AthAX ~= nil then
- ATH.Axis = AthAX end
- if SecondaryAxis ~= nil then
- ATH.SecondaryAxis = SecondaryAxis end
- end))
- end
- function getAttachment0(attachmentName,Rcharacter)
- for i, child in pairs(GatherAllInstances(Rcharacter)) do
- local attachment = child:FindFirstChild(attachmentName)
- if attachment then
- return attachment
- end
- end
- end
- function makrag(Rcharacter)
- --HitModel
- local camera = workspace.CurrentCamera
- --Make it so ragdoll can't collide with invisible HRP, but don't let HRP fall through map and be destroyed in process
- coroutine.resume(coroutine.create(function()
- if Rcharacter:FindFirstChild("HumanoidRootPart")then
- Rcharacter.HumanoidRootPart.Anchored = true
- Rcharacter.HumanoidRootPart.CanCollide = false
- --- Rcharacter.HumanoidRootPart.Position = Vector3.new(0,-10,0)
- Rcharacter.HumanoidRootPart.Parent = nil
- end
- end))
- --Helps to fix constraint spasms
- recurse(Rcharacter, 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
- coroutine.resume(coroutine.create(function()
- if Rcharacter:FindFirstChild("Torso")then
- local RMT = Rcharacter:FindFirstChild("Torso")
- local RMH = Rcharacter:FindFirstChild("Head")
- local RLA = Rcharacter:FindFirstChild("Left Arm")
- local RRA = Rcharacter:FindFirstChild("Right Arm")
- local RLL = Rcharacter:FindFirstChild("Left Leg")
- local RRL = Rcharacter:FindFirstChild("Right Leg")
- --MakeAth(RMH,"",0,0,0)
- MakeAth(RMH,"NeckRigAttachment",0,-.5,0)
- MakeAth(RRA,"RightShoulderRigAttachment",-0.4, 0.8, 0,Vector3.new(-180, 0, 90),Vector3.new(0, -1, -0),Vector3.new(0, 1, 0))
- MakeAth(RLA,"LeftShoulderRigAttachment",0.4, 0.8, 0,Vector3.new(-180, 0, 90),Vector3.new(0, -1, -0),Vector3.new(-1, 0, 0))
- MakeAth(RRL,"RightHipRigAttachment",0, 1, 0,Vector3.new(90, -90, 0),Vector3.new(0, -1, -0),Vector3.new(0, -0, 1))
- MakeAth(RLL,"LeftHipRigAttachment",0, 1, 0,Vector3.new(90, -90, 0),Vector3.new(0, -1, -0),Vector3.new(0, -0, 1))
- ------------------------------------------------------
- MakeAth(RMT,"NeckRigAttachment",0, 1, 0)
- MakeAth(RMT,"RightShoulderRigAttachment",1, 0.8, 0,Vector3.new(-180, 0, 0),Vector3.new(1, -0, 0),Vector3.new(0, -1, 0))
- MakeAth(RMT,"LeftShoulderRigAttachment",-1, 0.8, 0,Vector3.new(0, 0, -180),Vector3.new(-1, -0, 0),Vector3.new(0, -1, 0))
- MakeAth(RMT,"RightHipRigAttachment",0.5, -1.1, 0,Vector3.new(90, -90, 0),Vector3.new(0, -1, -0),Vector3.new(0, -0, 1))
- MakeAth(RMT,"LeftHipRigAttachment",-0.5, -1.1, 0,Vector3.new(90, -90, 0),Vector3.new(0, -1, -0),Vector3.new(0, -0, 1))
- coroutine.resume(coroutine.create(function()
- local LAT = Instance.new("BallSocketConstraint")
- LAT.Parent = RMT
- LAT.Attachment0 = RLA.LeftShoulderRigAttachment
- LAT.Attachment1 = RMT.LeftShoulderRigAttachment
- LAT.Enabled = true
- LAT.LimitsEnabled=true
- LAT.UpperAngle=70
- end))
- coroutine.resume(coroutine.create(function()
- local RAT = Instance.new("BallSocketConstraint")
- RAT.Parent = RMT
- RAT.Attachment0 = RRA.RightShoulderRigAttachment
- RAT.Attachment1 = RMT.RightShoulderRigAttachment
- RAT.Enabled = true
- RAT.LimitsEnabled=true
- RAT.UpperAngle=70
- end))
- coroutine.resume(coroutine.create(function()
- local TLL = Instance.new("BallSocketConstraint")
- TLL.Parent = RMT
- TLL.Attachment0 = RLL.LeftHipRigAttachment
- TLL.Attachment1 = RMT.LeftHipRigAttachment
- TLL.Enabled = true
- TLL.LimitsEnabled=true
- TLL.UpperAngle=70
- end))
- coroutine.resume(coroutine.create(function()
- local TRL = Instance.new("BallSocketConstraint")
- TRL.Parent = RMT
- TRL.Attachment0 = RRL.RightHipRigAttachment
- TRL.Attachment1 = RMT.RightHipRigAttachment
- TRL.Enabled = true
- TRL.LimitsEnabled=true
- TRL.UpperAngle=70
- end))
- end
- end))
- coroutine.resume(coroutine.create(function()
- ragdollJoint(Rcharacter.LowerTorso, Rcharacter.UpperTorso, "WaistRigAttachment", "BallSocket", {
- {"LimitsEnabled",true};
- {"UpperAngle",5};
- }) end)) coroutine.resume(coroutine.create(function()
- local NeckProperties = {
- {"LimitsEnabled", true};
- {"UpperAngle",5};
- }
- local Rtorso = Rcharacter:FindFirstChild("Torso") or Rcharacter:FindFirstChild("UpperTorso")
- ragdollJoint(Rtorso, Rcharacter.Head, "NeckRigAttachment", "Hinge", NeckProperties)
- end)) coroutine.resume(coroutine.create(function()
- local handProperties = {
- {"LimitsEnabled", true};
- {"UpperAngle",0};
- {"LowerAngle",0};
- }
- ragdollJoint(Rcharacter.LeftLowerArm, Rcharacter.LeftHand, "LeftWristRigAttachment", "Hinge", handProperties)
- ragdollJoint(Rcharacter.RightLowerArm, Rcharacter.RightHand, "RightWristRigAttachment", "Hinge", handProperties)
- end)) coroutine.resume(coroutine.create(function()
- local shinProperties = {
- {"LimitsEnabled", true};
- {"UpperAngle", 0};
- {"LowerAngle", -75};
- }
- ragdollJoint(Rcharacter.LeftUpperLeg, Rcharacter.LeftLowerLeg, "LeftKneeRigAttachment", "Hinge", shinProperties)
- ragdollJoint(Rcharacter.RightUpperLeg, Rcharacter.RightLowerLeg, "RightKneeRigAttachment", "Hinge", shinProperties)
- end)) coroutine.resume(coroutine.create(function()
- local footProperties = {
- {"LimitsEnabled", true};
- {"UpperAngle", 15};
- {"LowerAngle", -45};
- }
- ragdollJoint(Rcharacter.LeftLowerLeg, Rcharacter.LeftFoot, "LeftAnkleRigAttachment", "Hinge", footProperties)
- ragdollJoint(Rcharacter.RightLowerLeg, Rcharacter.RightFoot, "RightAnkleRigAttachment", "Hinge", footProperties)
- end))
- --TODO fix ability for socket to turn backwards whenn ConeConstraints are shipped
- coroutine.resume(coroutine.create(function()
- ragdollJoint(Rcharacter.UpperTorso, Rcharacter.LeftUpperArm, "LeftShoulderRigAttachment", "BallSocket") end)) coroutine.resume(coroutine.create(function()
- ragdollJoint(Rcharacter.LeftUpperArm, Rcharacter.LeftLowerArm, "LeftElbowRigAttachment", "BallSocket") end)) coroutine.resume(coroutine.create(function()
- ragdollJoint(Rcharacter.UpperTorso, Rcharacter.RightUpperArm, "RightShoulderRigAttachment", "BallSocket") end)) coroutine.resume(coroutine.create(function()
- ragdollJoint(Rcharacter.RightUpperArm, Rcharacter.RightLowerArm, "RightElbowRigAttachment", "BallSocket") end)) coroutine.resume(coroutine.create(function()
- ragdollJoint(Rcharacter.LowerTorso, Rcharacter.LeftUpperLeg, "LeftHipRigAttachment", "BallSocket") end)) coroutine.resume(coroutine.create(function()
- ragdollJoint(Rcharacter.LowerTorso, Rcharacter.RightUpperLeg, "RightHipRigAttachment", "BallSocket") end))
- for i = 0,2 do
- coroutine.resume(coroutine.create(function()
- for _,child in next,Rcharacter: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 part.CanCollide = false
- local attachment1 = part:FindFirstChildOfClass("Attachment")
- local attachment0 = getAttachment0(attachment1.Name,Rcharacter)
- 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 HatProperties = {
- {"LimitsEnabled", true};
- {"UpperAngle", 0};
- {"LowerAngle", -0};
- }
- coroutine.resume(coroutine.create(function()
- wait()
- local rg = ragdollJoint(attachment0.Parent, part, ""..attachment1.Name, "Hinge", HatProperties)
- end))
- end
- end
- end
- end
- end
- end))
- wait(0.5)
- end
- for _,v in pairs(Rcharacter:GetChildren()) do
- if v:isA("Script") or v:isA("LocalScript") then
- v:Destroy()
- end
- end
- coroutine.resume(coroutine.create(function()
- wait(1)
- for _,v3 in pairs(game:GetService("Players"):GetChildren()) do
- coroutine.resume(coroutine.create(function()
- if v3:isA("Player") and v3.Character == Rcharacter then
- Rcharacter.Archivable=true
- local ORcharacter = Rcharacter:Clone()
- --Rcharacter2.Archivable=false
- --Rcharacter3.Archivable=false
- ORcharacter.Parent = Rcharacter.Parent
- local Rhum = ORcharacter:FindFirstChildOfClass("Humanoid")
- Rhum.PlatformStand = true
- Rhum.Health = Rhum.MaxHealth
- Rcharacter:Destroy()
- wait()
- Rhum.Health = 0
- game:GetService("Debris"):AddItem(ORcharacter, 380)
- end
- end))
- end
- end))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement