Advertisement
Void_scripter0

Ragdoll

Feb 2nd, 2019
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.47 KB | None | 0 0
  1. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  2. local Player,game,owner = owner,game
  3. local RealPlayer = Player
  4. do
  5. print("FE Compatibility code by Mokiros | Showcase by Bacon Hair!")
  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.  
  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
  143. end
  144. --By Rufus14 (FINALLY I KNOW HOW TO MAKE A RAGDOLL :D)
  145. --PRESS "R" TO RAGDOLLIFY
  146. mouse = game.Players.LocalPlayer:GetMouse()
  147. using = false
  148. ragdolling = false
  149. hit = Instance.new("Sound", game.Players.LocalPlayer.Character.Torso)
  150. hit.SoundId = "rbxassetid://1542642349"
  151. hit.Volume = 2
  152. hit1 = Instance.new("Sound", game.Players.LocalPlayer.Character.Torso)
  153. hit1.SoundId = "rbxassetid://1542642349"
  154. hit1.Volume = 2
  155. hit2 = Instance.new("Sound", game.Players.LocalPlayer.Character.Torso)
  156. hit2.SoundId = "rbxassetid://1542642349"
  157. hit2.Volume = 2
  158. hit3 = Instance.new("Sound", game.Players.LocalPlayer.Character.Torso)
  159. hit3.SoundId = "rbxassetid://1542642349"
  160. hit3.Volume = 2
  161. hit3.TimePosition = 0.33
  162.  
  163. stand = Instance.new("Sound", game.Players.LocalPlayer.Character.Torso)
  164. stand.SoundId = "rbxassetid://162456532"
  165. stand.Volume = 3
  166.  
  167. print("Press R to ragdollify")
  168. function respawn(key)
  169. key = key:lower()
  170. if key == "t" then
  171. stand:Play()
  172. if ragdolling then
  173. ragdolling = false
  174. lshclone.Parent = game.Players.LocalPlayer.Character.Torso
  175. glue:destroy()
  176. rshclone.Parent = game.Players.LocalPlayer.Character.Torso
  177. glue1:destroy()
  178. lhclone.Parent = game.Players.LocalPlayer.Character.Torso
  179. glue11:destroy()
  180. rhclone.Parent = game.Players.LocalPlayer.Character.Torso
  181. glue111:destroy()
  182. collider:destroy()
  183. collider1:destroy()
  184. collider11:destroy()
  185. collider111:destroy()
  186. sensoring:destroy()
  187. sensoring1:destroy()
  188. game.Players.LocalPlayer.Character.Torso.SpotLight:destroy()
  189. game.Players.LocalPlayer.Character.Humanoid.PlatformStand = false
  190. end
  191. end
  192. end
  193. mouse.KeyDown:connect(respawn)
  194. function ragdoll(key)
  195. key = key:lower()
  196. if key == "r" then
  197. if not ragdolling then
  198. ragdolling = true
  199. local light = Instance.new("SpotLight", game.Players.LocalPlayer.Character.Torso)
  200. game.Players.LocalPlayer.Character.Humanoid.PlatformStand = true
  201. lshclone = game.Players.LocalPlayer.Character.Torso["Left Shoulder"]:Clone()
  202. rshclone = game.Players.LocalPlayer.Character.Torso["Right Shoulder"]:Clone()
  203. lhclone = game.Players.LocalPlayer.Character.Torso["Left Hip"]:Clone()
  204. rhclone = game.Players.LocalPlayer.Character.Torso["Right Hip"]:Clone()
  205. local leftarm = game.Players.LocalPlayer.Character["Left Arm"]
  206. local rightrm = game.Players.LocalPlayer.Character["Right Arm"]
  207. local leftleg = game.Players.LocalPlayer.Character["Left Leg"]
  208. local rightleg = game.Players.LocalPlayer.Character["Right Leg"]
  209. game.Players.LocalPlayer.Character.Torso["Left Hip"]:destroy()
  210. local head = game.Players.LocalPlayer.Character.Head
  211. glue = Instance.new("Glue", game.Players.LocalPlayer.Character.Torso)
  212. glue.Part0 = game.Players.LocalPlayer.Character.Torso
  213. glue.Part1 = leftleg
  214. glue.Name = "Left leg"
  215. collider = Instance.new("Part", leftleg)
  216. collider.Position = Vector3.new(0,999,0)
  217. collider.Size = Vector3.new(1.5, 1, 1)
  218. collider.Shape = "Cylinder"
  219. local weld = Instance.new("Weld", collider)
  220. weld.Part0 = leftleg
  221. weld.Part1 = collider
  222. weld.C0 = CFrame.new(0,-0.2,0) * CFrame.fromEulerAnglesXYZ(0, 0, math.pi/2)
  223. collider.TopSurface = "Smooth"
  224. collider.BottomSurface = "Smooth"
  225. collider.formFactor = "Symmetric"
  226. glue.C0 = CFrame.new(-0.5, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  227. glue.C1 = CFrame.new(-0, 1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  228. collider.Transparency = 1
  229. ------------
  230. game.Players.LocalPlayer.Character.Torso["Right Hip"]:destroy()
  231. glue1 = Instance.new("Glue", game.Players.LocalPlayer.Character.Torso)
  232. glue1.Part0 = game.Players.LocalPlayer.Character.Torso
  233. glue1.Part1 = rightleg
  234. glue1.Name = "Right leg"
  235. collider1 = Instance.new("Part", rightleg)
  236. collider1.Position = Vector3.new(0,9999,0)
  237. collider1.Size = Vector3.new(1.5, 1, 1)
  238. collider1.Shape = "Cylinder"
  239. local weld1 = Instance.new("Weld", collider1)
  240. weld1.Part0 = rightleg
  241. weld1.Part1 = collider1
  242. weld1.C0 = CFrame.new(0,-0.2,0) * CFrame.fromEulerAnglesXYZ(0, 0, math.pi/2)
  243. collider1.TopSurface = "Smooth"
  244. collider1.BottomSurface = "Smooth"
  245. collider1.formFactor = "Symmetric"
  246. glue1.C0 = CFrame.new(0.5, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  247. glue1.C1 = CFrame.new(0, 1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  248. collider1.Transparency = 1
  249. ------------
  250. game.Players.LocalPlayer.Character.Torso["Right Shoulder"]:destroy()
  251. glue11 = Instance.new("Glue", game.Players.LocalPlayer.Character.Torso)
  252. glue11.Part0 = game.Players.LocalPlayer.Character.Torso
  253. glue11.Part1 = rightrm
  254. glue11.Name = "Right shoulder"
  255. collider11 = Instance.new("Part", rightrm)
  256. collider11.Position = Vector3.new(0,9999,0)
  257. collider11.Size = Vector3.new(1.8,1,1)
  258. collider11.Shape = "Cylinder"
  259. local weld11 = Instance.new("Weld", collider11)
  260. weld11.Part0 = rightrm
  261. weld11.Part1 = collider11
  262. weld11.C0 = CFrame.new(0,-0.2,0) * CFrame.fromEulerAnglesXYZ(0, 0, math.pi/2)
  263. collider11.TopSurface = "Smooth"
  264. collider11.BottomSurface = "Smooth"
  265. collider11.formFactor = "Symmetric"
  266. glue11.C0 = CFrame.new(1.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
  267. glue11.C1 = CFrame.new(0, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
  268. collider11.Transparency = 1
  269. ------------
  270. game.Players.LocalPlayer.Character.Torso["Left Shoulder"]:destroy()
  271. glue111 = Instance.new("Glue", game.Players.LocalPlayer.Character.Torso)
  272. glue111.Part0 = game.Players.LocalPlayer.Character.Torso
  273. glue111.Part1 = leftarm
  274. glue111.Name = "Left shoulder"
  275. collider111 = Instance.new("Part", leftarm)
  276. collider111.Position = Vector3.new(0,9999,0)
  277. collider111.Size = Vector3.new(1.5, 1, 1)
  278. collider111.Shape = "Cylinder"
  279. local weld111 = Instance.new("Weld", collider111)
  280. weld111.Part0 = leftarm
  281. weld111.Part1 = collider111
  282. weld111.C0 = CFrame.new(0,-0.2,0) * CFrame.fromEulerAnglesXYZ(0, 0, math.pi/2)
  283. collider111.TopSurface = "Smooth"
  284. collider111.BottomSurface = "Smooth"
  285. collider111.formFactor = "Symmetric"
  286. glue111.C0 = CFrame.new(-1.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  287. glue111.C1 = CFrame.new(0, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  288. collider111.Transparency = 1
  289. -----------------
  290. sensoring = Instance.new("Part", game.Players.LocalPlayer.Character.Torso)
  291. sensoring.Size = Vector3.new(1.2,1.1,0.8)
  292. sensoring.CanCollide = false
  293. sensoring.Position = game.Players.LocalPlayer.Character.Torso.Position
  294. local welder = Instance.new("Weld", sensoring)
  295. welder.Part0 = game.Players.LocalPlayer.Character.Torso
  296. welder.Part1 = sensoring
  297. welder.C0 = welder.C0 * CFrame.new(0,0,1.05)
  298. sensoring.Transparency = 1
  299. -----------------
  300. sensoring1 = Instance.new("Part", game.Players.LocalPlayer.Character.Torso)
  301. sensoring1.Size = Vector3.new(1.2,1.1,0.8)
  302. sensoring1.CanCollide = false
  303. sensoring1.Position = game.Players.LocalPlayer.Character.Torso.Position
  304. local welder1 = Instance.new("Weld", sensoring)
  305. welder1.Part0 = game.Players.LocalPlayer.Character.Torso
  306. welder1.Part1 = sensoring1
  307. welder1.C0 = welder1.C0 * CFrame.new(0,0,-1.05)
  308. sensoring1.Transparency = 1
  309. local function touch()
  310. if not using then
  311. using = true
  312. local Math = math.random(1,4)
  313. if Math == 1 then
  314. hit:Play()
  315. end
  316. if Math == 2 then
  317. hit1:Play()
  318. end
  319. if Math == 3 then
  320. hit2:Play()
  321. end
  322. if Math == 4 then
  323. hit3:Play()
  324. end
  325. wait(0.1)
  326. using = false
  327. end
  328. end
  329. sensoring.Touched:connect(touch)
  330. sensoring1.Touched:connect(touch)
  331. end
  332.  
  333. end
  334. end
  335. mouse.KeyDown:connect(ragdoll)
  336. --di ent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement