SHOW:
|
|
- or go back to the newest paste.
| 1 | - | -- BY thebluefox64/mitten777 |
| 1 | + | -- This script has been converted to FE by iPxter |
| 2 | ||
| 3 | - | local Player,game,owner = owner,game |
| 3 | + | |
| 4 | - | local RealPlayer = Player |
| 4 | + | |
| 5 | local Player,Mouse,mouse,UserInputService,ContextActionService = owner | |
| 6 | do | |
| 7 | print("FE Compatibility code by Mokiros | Translated to FE by iPxter")
| |
| 8 | script.Parent = Player.Character | |
| 9 | ||
| 10 | --RemoteEvent for communicating | |
| 11 | local Event = Instance.new("RemoteEvent")
| |
| 12 | Event.Name = "UserInput_Event" | |
| 13 | ||
| 14 | --Fake event to make stuff like Mouse.KeyDown work | |
| 15 | local function fakeEvent() | |
| 16 | local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
| |
| 17 | t.connect = t.Connect | |
| 18 | return t | |
| 19 | end | |
| 20 | ||
| 21 | --Creating fake input objects with fake variables | |
| 22 | local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
| |
| 23 | local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
| |
| 24 | local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
| |
| 25 | CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
| |
| 26 | end} | |
| 27 | --Merged 2 functions into one by checking amount of arguments | |
| 28 | CAS.UnbindAction = CAS.BindAction | |
| 29 | ||
| 30 | --This function will trigger the events that have been :Connect()'ed | |
| 31 | local function te(self,ev,...) | |
| 32 | local t = m[ev] | |
| 33 | if t and t._fakeEvent and t.Function then | |
| 34 | t.Function(...) | |
| 35 | end | |
| 36 | end | |
| 37 | m.TrigEvent = te | |
| 38 | UIS.TrigEvent = te | |
| 39 | ||
| 40 | Event.OnServerEvent:Connect(function(plr,io) | |
| 41 | if plr~=Player then return end | |
| 42 | if io.isMouse then | |
| 43 | m.Target = io.Target | |
| 44 | m.Hit = io.Hit | |
| 45 | else | |
| 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 UIS = game:GetService("UserInputService")
| |
| 66 | local input = function(io,a) | |
| 67 | if a then return end | |
| 68 | --Since InputObject is a client-side instance, we create and pass table instead | |
| 69 | Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
| |
| 70 | end | |
| 71 | UIS.InputBegan:Connect(input) | |
| 72 | UIS.InputEnded:Connect(input) | |
| 73 | ||
| 74 | local Mouse = Player:GetMouse() | |
| 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 | Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS | |
| 85 | end | |
| 86 | ||
| 87 | ||
| 88 | wait(0.001) | |
| 89 | ||
| 90 | local cleanUpTime = 60 -- change this to whatever you want | |
| 91 | ||
| 92 | local function NewHingePart() | |
| 93 | local B = Instance.new("Part")
| |
| 94 | B.TopSurface = 0 B.BottomSurface = 0 | |
| 95 | B.Shape = "Ball" | |
| 96 | B.Size = Vector3.new(1, 1, 1) | |
| 97 | B.Transparency = 1 B.CanCollide = true | |
| 98 | return B | |
| 99 | end | |
| 100 | local function CreateJoint(j_type, p0, p1, c0, c1) | |
| 101 | local nj = Instance.new(j_type) | |
| 102 | nj.Part0 = p0 nj.part1 = p1 | |
| 103 | if c0 ~= nil then nj.C0 = c0 end | |
| 104 | if c1 ~= nil then nj.C1 = c1 end | |
| 105 | nj.Parent = p0 | |
| 106 | end | |
| 107 | ||
| 108 | local AttactmentData = { --Limb socket attaching to Torso
| |
| 109 | --["AttachmentTag"] = {part_name, part_attachment, torso_attachment, relative_position}
| |
| 110 | ["RA"] = {"Right Arm", CFrame.new(0, 0.5, 0), CFrame.new(1.5, 0.5, 0), CFrame.new(1.5, 0, 0)},
| |
| 111 | ["LA"] = {"Left Arm", CFrame.new(0, 0.5, 0), CFrame.new(-1.5, 0.5, 0), CFrame.new(-1.5, 0, 0)},
| |
| 112 | ["RL"] = {"Right Leg", CFrame.new(0, 0.5, 0), CFrame.new(0.5, -1.5, 0), CFrame.new(0.5, -2, 0)},
| |
| 113 | ["LL"] = {"Left Leg", CFrame.new(0, 0.5, 0), CFrame.new(-0.5, -1.5, 0), CFrame.new(-0.5, -2, 0)},
| |
| 114 | } | |
| 115 | ||
| 116 | local collision_part = Instance.new("Part")
| |
| 117 | collision_part.Name = "CP" | |
| 118 | collision_part.TopSurface = Enum.SurfaceType.Smooth | |
| 119 | collision_part.BottomSurface = Enum.SurfaceType.Smooth | |
| 120 | collision_part.Size = Vector3.new(1, 1.5, 1) | |
| 121 | collision_part.Transparency = 1 | |
| 122 | ||
| 123 | local camera = workspace.CurrentCamera | |
| 124 | local char = script.Parent | |
| 125 | ||
| 126 | function RagdollV3() | |
| 127 | char.Archivable = true | |
| 128 | local ragdoll = char:clone() | |
| 129 | char.Archivable = false | |
| 130 | ||
| 131 | local hdv = ragdoll:FindFirstChild("Head")
| |
| 132 | ||
| 133 | --Clears the real character from everything but humanoid | |
| 134 | for _, obj in pairs(char:GetChildren()) do | |
| 135 | if not obj:IsA("Humanoid") then
| |
| 136 | obj:destroy() | |
| 137 | end | |
| 138 | end | |
| 139 | ||
| 140 | --set up the ragdoll | |
| 141 | local function scan(ch) | |
| 142 | for i = 1, #ch do | |
| 143 | scan(ch[i]:GetChildren()) | |
| 144 | if (ch[i]:IsA("ForceField") or ch[i].Name == "HumanoidRootPart") or ((ch[i]:IsA("Weld") or ch[i]:IsA("Motor6D")) and ch[i].Name ~= "HeadWeld" and ch[i].Name ~= "AttachementWeld") then
| |
| 145 | ch[i]:destroy() | |
| 146 | end | |
| 147 | end | |
| 148 | end | |
| 149 | scan(ragdoll:GetChildren()) | |
| 150 | local function scanc(ch) | |
| 151 | for _, obj in pairs(ch:GetChildren()) do | |
| 152 | scanc(obj) | |
| 153 | if obj:IsA("Script") or obj:IsA("LocalScript") or ((obj:IsA("Weld") or obj:IsA("Motor6D")) and obj.Name ~= "AttachementWeld") or obj:IsA("ForceField") or (obj:IsA("Snap") and obj.Parent.Name == "Torso")
| |
| 154 | or obj:IsA("ParticleEmitter")then
| |
| 155 | obj:destroy() | |
| 156 | elseif obj:IsA("BasePart") then
| |
| 157 | obj.Velocity = Vector3.new(0, 0, 0) | |
| 158 | obj.RotVelocity = Vector3.new(0, 0, 0) | |
| 159 | if obj.Parent:IsA("Accessory") then
| |
| 160 | obj.CanCollide = false | |
| 161 | end | |
| 162 | end | |
| 163 | end | |
| 164 | end | |
| 165 | scanc(ragdoll) | |
| 166 | ||
| 167 | local f_head | |
| 168 | ||
| 169 | local fhum = ragdoll:FindFirstChild("Humanoid")
| |
| 170 | fhum.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff | |
| 171 | fhum.PlatformStand = true | |
| 172 | fhum.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None | |
| 173 | fhum.Name = "RagdollHumanoid" | |
| 174 | ||
| 175 | local Torso = ragdoll:FindFirstChild("Torso")
| |
| 176 | if Torso then | |
| 177 | Torso.Velocity = Vector3.new(math.random(), 0.0000001, math.random()).unit * 5 + (Vector3.new(0, 0.15, 0)) | |
| 178 | local Head = ragdoll:FindFirstChild("Head")
| |
| 179 | if Head then | |
| 180 | camera.CameraSubject = Head | |
| 181 | CreateJoint("Weld", Torso, Head, CFrame.new(0, 1.5, 0))
| |
| 182 | end | |
| 183 | ||
| 184 | for att_tag, att_data in pairs(AttactmentData) do | |
| 185 | local get_limb = ragdoll:FindFirstChild(att_data[1]) | |
| 186 | if get_limb ~= nil then | |
| 187 | ||
| 188 | local att1 = Instance.new("Attachment")
| |
| 189 | att1.Name = att_tag | |
| 190 | att1.CFrame = att_data[2] | |
| 191 | att1.Parent = get_limb | |
| 192 | ||
| 193 | local att2 = Instance.new("Attachment")
| |
| 194 | att2.Name = att_tag | |
| 195 | att2.CFrame = att_data[3] | |
| 196 | att2.Parent = Torso | |
| 197 | ||
| 198 | local socket = Instance.new("BallSocketConstraint")
| |
| 199 | socket.Name = att_tag .. "_SOCKET" | |
| 200 | socket.Attachment0 = att2 | |
| 201 | socket.Attachment1 = att1 | |
| 202 | socket.Radius = 0 | |
| 203 | socket.Parent = Torso | |
| 204 | ||
| 205 | get_limb.CanCollide = false | |
| 206 | ||
| 207 | local cp = collision_part:Clone() | |
| 208 | local cp_weld = Instance.new("Weld")
| |
| 209 | cp_weld.C0 = CFrame.new(0, -0.25, 0) | |
| 210 | cp_weld.Part0 = get_limb | |
| 211 | cp_weld.Part1 = cp | |
| 212 | cp_weld.Parent = cp | |
| 213 | cp.Parent = ragdoll | |
| 214 | end | |
| 215 | end | |
| 216 | end | |
| 217 | ragdoll.Parent = workspace | |
| 218 | game:GetService("Debris"):AddItem(ragdoll, cleanUpTime)
| |
| 219 | fhum.MaxHealth = 100 | |
| 220 | fhum.Health = fhum.MaxHealth | |
| 221 | end | |
| 222 | ||
| 223 | char.Humanoid.Died:connect(RagdollV3) |