SHOW:
|
|
- or go back to the newest paste.
| 1 | local isScriptNil = false | |
| 2 | ||
| 3 | local PlrName = "jericoalejo" | |
| 4 | local Plrs = game:GetService("Players")
| |
| 5 | local RunService = game:GetService("RunService")
| |
| 6 | local Content = game:GetService("ContentProvider")
| |
| 7 | local LP = Plrs.LocalPlayer | |
| 8 | local Char = LP.Character | |
| 9 | local PlrGui = LP.PlayerGui | |
| 10 | local Backpack = LP.Backpack | |
| 11 | local Mouse = LP:GetMouse() | |
| 12 | ||
| 13 | local Camera = Workspace.CurrentCamera | |
| 14 | local LastCamCF = Camera.CoordinateFrame | |
| 15 | local AnimJoints = {}
| |
| 16 | local Cons = {}
| |
| 17 | local mDown = false | |
| 18 | local Multi = false | |
| 19 | local Grabbing = false | |
| 20 | local Current = {}
| |
| 21 | local Alpha = 1 | |
| 22 | local LightNum = 1 | |
| 23 | ||
| 24 | Current.Part = nil | |
| 25 | Current.BP = nil | |
| 26 | Current.BA = nil | |
| 27 | Current.Mass = nil | |
| 28 | ||
| 29 | local LastPart = nil | |
| 30 | ||
| 31 | local Head = Char["Head"] | |
| 32 | local Torso = Char["Torso"] | |
| 33 | local Humanoid = Char["Humanoid"] | |
| 34 | local LA = Char["Left Arm"] | |
| 35 | local RA = Char["Right Arm"] | |
| 36 | local LL = Char["Left Leg"] | |
| 37 | local RL = Char["Right Leg"] | |
| 38 | ||
| 39 | local LS, RS; | |
| 40 | ||
| 41 | local OrigLS = Torso["Left Shoulder"] | |
| 42 | local OrigRS = Torso["Right Shoulder"] | |
| 43 | ||
| 44 | for _,v in pairs(Char:GetChildren()) do | |
| 45 | if v.Name == ModID then | |
| 46 | v:Destroy() | |
| 47 | end | |
| 48 | end | |
| 49 | ||
| 50 | for _,v in pairs(PlrGui:GetChildren()) do | |
| 51 | if v.Name == "PadsGui" then | |
| 52 | v:Destroy() | |
| 53 | end | |
| 54 | end | |
| 55 | ||
| 56 | local ModID = "Pads" | |
| 57 | local Objects = {}
| |
| 58 | local Grav = 196.2 | |
| 59 | ||
| 60 | local sin=math.sin | |
| 61 | local cos=math.cos | |
| 62 | local max=math.max | |
| 63 | local min=math.min | |
| 64 | local atan2=math.atan2 | |
| 65 | local random=math.random | |
| 66 | local tau = 2 * math.pi | |
| 67 | ||
| 68 | local BodyObjects = {
| |
| 69 | ["BodyVelocity"] = true; | |
| 70 | ["BodyAngularVelocity"] = true; | |
| 71 | ["BodyForce"] = true; | |
| 72 | ["BodyThrust"] = true; | |
| 73 | ["BodyPosition"] = true; | |
| 74 | ["RocketPropulsion"] = true; | |
| 75 | } | |
| 76 | ||
| 77 | if LP.Name == PlrName and isScriptNil then | |
| 78 | script.Parent = nil | |
| 79 | end | |
| 80 | ||
| 81 | LP.CameraMode = "Classic" | |
| 82 | ||
| 83 | local Assets = {
| |
| 84 | } | |
| 85 | ||
| 86 | local LS0, LS1 = OrigLS.C0, OrigLS.C1 | |
| 87 | local RS0, RS1 = OrigRS.C0, OrigRS.C1 | |
| 88 | ||
| 89 | for i,v in pairs(Assets) do | |
| 90 | local ID = tostring(Assets[i]) | |
| 91 | Assets[i] = "http://www.roblox.com/asset/?id=" .. ID | |
| 92 | Content:Preload("http://www.roblox.com/asset/?id=" .. ID)
| |
| 93 | end | |
| 94 | ||
| 95 | function QuaternionFromCFrame(cf) | |
| 96 | local mx, my, mz, m00, m01, m02, m10, m11, m12, m20, m21, m22 = cf:components(); | |
| 97 | local trace = m00 + m11 + m22 if trace > 0 then | |
| 98 | local s = math.sqrt(1 + trace); | |
| 99 | local recip = 0.5/s; | |
| 100 | return (m21-m12)*recip, (m02-m20)*recip, (m10-m01)*recip, s*0.5; | |
| 101 | else | |
| 102 | local i = 0; | |
| 103 | if m11 > m00 then | |
| 104 | i = 1; | |
| 105 | end; | |
| 106 | if m22 > (i == 0 and m00 or m11) then | |
| 107 | i = 2 end if i == 0 then | |
| 108 | local s = math.sqrt(m00-m11-m22+1); | |
| 109 | local recip = 0.5/s return 0.5*s, (m10+m01)*recip, (m20+m02)*recip, (m21-m12)*recip; | |
| 110 | elseif i == 1 then | |
| 111 | local s = math.sqrt(m11-m22-m00+1); | |
| 112 | local recip = 0.5/s; | |
| 113 | return (m01+m10)*recip, 0.5*s, (m21+m12)*recip, (m02-m20)*recip ; | |
| 114 | elseif i == 2 then | |
| 115 | local s = math.sqrt(m22-m00-m11+1); | |
| 116 | local recip = 0.5/s; | |
| 117 | return (m02+m20)*recip, (m12+m21)*recip, 0.5*s, (m10-m01)*recip; | |
| 118 | end; | |
| 119 | end; | |
| 120 | end; | |
| 121 | ||
| 122 | function QuaternionToCFrame(px, py, pz, x, y, z, w) | |
| 123 | local xs, ys, zs = x + x, y + y, z + z; | |
| 124 | local wx, wy, wz = w*xs, w*ys, w*zs; | |
| 125 | local xx = x*xs; | |
| 126 | local xy = x*ys; | |
| 127 | local xz = x*zs; | |
| 128 | local yy = y*ys; | |
| 129 | local yz = y*zs; | |
| 130 | local zz = z*zs; | |
| 131 | return CFrame.new(px, py, pz,1-(yy+zz), xy - wz, xz + wy,xy + wz, 1-(xx+zz), yz - wx, xz - wy, yz + wx, 1-(xx+yy)) | |
| 132 | end; | |
| 133 | ||
| 134 | function QuaternionSlerp(a, b, t) | |
| 135 | local cosTheta = a[1]*b[1] + a[2]*b[2] + a[3]*b[3] + a[4]*b[4]; | |
| 136 | local startInterp, finishInterp; | |
| 137 | if cosTheta >= 0.0001 then | |
| 138 | if (1 - cosTheta) > 0.0001 then | |
| 139 | local theta = math.acos(cosTheta); | |
| 140 | local invSinTheta = 1/math.sin(theta); | |
| 141 | startInterp = math.sin((1-t)*theta)*invSinTheta; | |
| 142 | finishInterp = math.sin(t*theta)*invSinTheta; | |
| 143 | else | |
| 144 | startInterp = 1-t finishInterp = t; | |
| 145 | end; | |
| 146 | else | |
| 147 | if (1+cosTheta) > 0.0001 then | |
| 148 | local theta = math.acos(-cosTheta); | |
| 149 | local invSinTheta = 1/math.sin(theta); | |
| 150 | startInterp = math.sin((t-1)*theta)*invSinTheta; | |
| 151 | finishInterp = math.sin(t*theta)*invSinTheta; | |
| 152 | else startInterp = t-1 finishInterp = t; | |
| 153 | end; | |
| 154 | end; | |
| 155 | return a[1]*startInterp + b[1]*finishInterp, a[2]*startInterp + b[2]*finishInterp, a[3]*startInterp + b[3]*finishInterp, a[4]*startInterp + b[4]*finishInterp; | |
| 156 | end; | |
| 157 | ||
| 158 | function CLerp(a,b,t) | |
| 159 | local qa={QuaternionFromCFrame(a)};
| |
| 160 | local qb={QuaternionFromCFrame(b)};
| |
| 161 | local ax,ay,az=a.x,a.y,a.z; | |
| 162 | local bx,by,bz=b.x,b.y,b.z; | |
| 163 | local _t=1-t; | |
| 164 | return QuaternionToCFrame(_t*ax+t*bx,_t*ay+t*by,_t*az+t*bz,QuaternionSlerp(qa, qb, t)); | |
| 165 | end | |
| 166 | ||
| 167 | function GetWeld(weld) | |
| 168 | local obj | |
| 169 | for i, v in pairs(AnimJoints) do | |
| 170 | if v[1] == weld then | |
| 171 | obj = v | |
| 172 | break | |
| 173 | end | |
| 174 | end | |
| 175 | if not obj then | |
| 176 | obj = {weld,NV}
| |
| 177 | table.insert(AnimJoints,obj) | |
| 178 | end | |
| 179 | return weld.C0.p, obj[2] | |
| 180 | end | |
| 181 | ||
| 182 | function SetWeld(weld, i, loops, origpos, origangle, nextpos, nextangle, override, overrideLower, smooth) | |
| 183 | smooth = smooth or 1 | |
| 184 | local obj | |
| 185 | for i, v in pairs(AnimJoints) do | |
| 186 | if v[1] == weld then | |
| 187 | obj = v | |
| 188 | break | |
| 189 | end | |
| 190 | end | |
| 191 | if not obj then | |
| 192 | obj = {weld,NV}
| |
| 193 | table.insert(AnimJoints,obj) | |
| 194 | end | |
| 195 | ||
| 196 | local perc = (smooth == 1 and math.sin((math.pi/2)/loops*i)) or i/loops | |
| 197 | ||
| 198 | local tox,toy,toz = 0,0,0 | |
| 199 | tox = math.abs(origangle.x - nextangle.x) *perc | |
| 200 | toy = math.abs(origangle.y - nextangle.y) *perc | |
| 201 | toz = math.abs(origangle.z - nextangle.z) *perc | |
| 202 | tox = ((origangle.x > nextangle.x and -tox) or tox) | |
| 203 | toy = ((origangle.y > nextangle.y and -toy) or toy) | |
| 204 | toz = ((origangle.z > nextangle.z and -toz) or toz) | |
| 205 | ||
| 206 | local tox2,toy2,toz2 = 0,0,0 | |
| 207 | tox2 = math.abs(origpos.x - nextpos.x) *perc | |
| 208 | toy2 = math.abs(origpos.y - nextpos.y) *perc | |
| 209 | toz2 = math.abs(origpos.z - nextpos.z) *perc | |
| 210 | tox2 = (origpos.x > nextpos.x and -tox2) or tox2 | |
| 211 | toy2 = (origpos.y > nextpos.y and -toy2) or toy2 | |
| 212 | toz2 = (origpos.z > nextpos.z and -toz2) or toz2 | |
| 213 | ||
| 214 | obj[2] = Vector3.new(origangle.x + tox, origangle.y + toy, origangle.z + toz) | |
| 215 | weld.C0 = CFrame.new(origpos.x + tox2,origpos.y + toy2,origpos.z + toz2) * CFrame.Angles(origangle.x + tox,origangle.y + toy,origangle.z + toz) | |
| 216 | end | |
| 217 | ||
| 218 | function RotateCamera(x, y) | |
| 219 | Camera.CoordinateFrame = CFrame.new(Camera.Focus.p) * (Camera.CoordinateFrame - Camera.CoordinateFrame.p) * CFrame.Angles(x, y, 0) * CFrame.new(0, 0, (Camera.CoordinateFrame.p - Camera.Focus.p).magnitude) | |
| 220 | end | |
| 221 | ||
| 222 | function GetAngles(cf) | |
| 223 | local lv = cf.lookVector | |
| 224 | return -math.asin(lv.y), math.atan2(lv.x, -lv.z) | |
| 225 | end | |
| 226 | ||
| 227 | local LastCamCF = Camera.CoordinateFrame | |
| 228 | ||
| 229 | function Look() | |
| 230 | if AlphaOn == true then | |
| 231 | local x, y = GetAngles(LastCamCF:toObjectSpace(Camera.CoordinateFrame)) | |
| 232 | Camera.CoordinateFrame = LastCamCF | |
| 233 | RotateCamera(x * -(Alpha), y * -(Alpha)) | |
| 234 | LastCamCF = Camera.CoordinateFrame | |
| 235 | end | |
| 236 | end | |
| 237 | ||
| 238 | function Cor(Func) | |
| 239 | local Ok, Err = coroutine.resume(coroutine.create(Func)) | |
| 240 | if not Ok then | |
| 241 | print(Err) | |
| 242 | end | |
| 243 | end | |
| 244 | ||
| 245 | function Cor2(Func) | |
| 246 | local Ok, Err = ypcall(Func) | |
| 247 | if not Ok then | |
| 248 | print(Err) | |
| 249 | end | |
| 250 | end | |
| 251 | ||
| 252 | function MakePads() | |
| 253 | -- 1 - VTelekinesis | |
| 254 | P1 = Instance.new("Model")
| |
| 255 | P1.Name = ModID | |
| 256 | ||
| 257 | -- 2 - RBase | |
| 258 | P2 = Instance.new("Part")
| |
| 259 | P2.CFrame = CFrame.new(Vector3.new(21.100008, 1.95000589, 11.899971)) * CFrame.Angles(-0, 0, -0) | |
| 260 | P2.FormFactor = Enum.FormFactor.Custom | |
| 261 | P2.Size = Vector3.new(0.799999952, 0.200000003, 0.800000012) | |
| 262 | P2.Anchored = true | |
| 263 | P2.BrickColor = BrickColor.new("White")
| |
| 264 | P2.Friction = 0.30000001192093 | |
| 265 | P2.Shape = Enum.PartType.Block | |
| 266 | P2.Name = "RBase" | |
| 267 | P2.Parent = P1 | |
| 268 | P2.Transparency = 1 | |
| 269 | -- 3 - Mesh | |
| 270 | P3 = Instance.new("CylinderMesh")
| |
| 271 | P3.Scale = Vector3.new(1, 0.5, 1) | |
| 272 | P3.Parent = P2 | |
| 273 | ||
| 274 | -- 4 - LBase | |
| 275 | P4 = Instance.new("Part")
| |
| 276 | P4.CFrame = CFrame.new(Vector3.new(18.100008, 1.95000589, 11.899971)) * CFrame.Angles(-0, 0, -0) | |
| 277 | P4.FormFactor = Enum.FormFactor.Custom | |
| 278 | P4.Size = Vector3.new(0.799999952, 0.200000003, 0.800000012) | |
| 279 | P4.Anchored = true | |
| 280 | P4.BrickColor = BrickColor.new("White")
| |
| 281 | P4.Friction = 0.30000001192093 | |
| 282 | P4.Shape = Enum.PartType.Block | |
| 283 | P4.Name = "LBase" | |
| 284 | P4.Parent = P1 | |
| 285 | P4.Transparency = 1 | |
| 286 | -- 5 - Mesh | |
| 287 | P5 = Instance.new("CylinderMesh")
| |
| 288 | P5.Scale = Vector3.new(1, 0.5, 1) | |
| 289 | P5.Parent = P4 | |
| 290 | ||
| 291 | -- 7 - Mesh | |
| 292 | P7 = Instance.new("CylinderMesh")
| |
| 293 | P7.Scale = Vector3.new(1, 0.5, 1) | |
| 294 | P7.Parent = P6 | |
| 295 | ||
| 296 | ||
| 297 | ||
| 298 | -- 9 - Mesh | |
| 299 | P9 = Instance.new("CylinderMesh")
| |
| 300 | P9.Scale = Vector3.new(1, 0.5, 1) | |
| 301 | P9.Parent = P8 | |
| 302 | ||
| 303 | ||
| 304 | ||
| 305 | -- 11 - Mesh | |
| 306 | P11 = Instance.new("CylinderMesh")
| |
| 307 | P11.Scale = Vector3.new(1, 0.5, 1) | |
| 308 | P11.Parent = P10 | |
| 309 | ||
| 310 | ||
| 311 | -- 13 - Mesh | |
| 312 | P13 = Instance.new("CylinderMesh")
| |
| 313 | P13.Scale = Vector3.new(1, 0.5, 1) | |
| 314 | P13.Parent = P12 | |
| 315 | ||
| 316 | ||
| 317 | -- 15 - Mesh | |
| 318 | P15 = Instance.new("CylinderMesh")
| |
| 319 | P15.Scale = Vector3.new(1, 0.5, 1) | |
| 320 | P15.Parent = P14 | |
| 321 | ||
| 322 | -- 17 - Mesh | |
| 323 | P17 = Instance.new("CylinderMesh")
| |
| 324 | P17.Scale = Vector3.new(1, 0.5, 1) | |
| 325 | P17.Parent = P16 | |
| 326 | ||
| 327 | P1.Parent = LP.Character | |
| 328 | P1:MakeJoints() | |
| 329 | return P1 | |
| 330 | end | |
| 331 | ||
| 332 | weldModel = function(model, unanchor, rooty) | |
| 333 | local parts = {}
| |
| 334 | local function recurse(object) | |
| 335 | if object:IsA("BasePart") then
| |
| 336 | table.insert(parts, object) | |
| 337 | end | |
| 338 | for _,child in pairs(object:GetChildren()) do | |
| 339 | recurse(child) | |
| 340 | end | |
| 341 | end | |
| 342 | recurse(model) | |
| 343 | ||
| 344 | local rootPart = rooty or parts[1] | |
| 345 | for _, part in pairs(parts) do | |
| 346 | local cframe = rootPart.CFrame:toObjectSpace(part.CFrame) | |
| 347 | local weld = Instance.new("Weld")
| |
| 348 | weld.Part0 = rootPart | |
| 349 | weld.Part1 = part | |
| 350 | weld.C0 = cframe | |
| 351 | weld.Parent = rootPart | |
| 352 | end | |
| 353 | ||
| 354 | if unanchor then | |
| 355 | for _, part in pairs(parts) do | |
| 356 | part.Anchored = false | |
| 357 | part.CanCollide = false | |
| 358 | end | |
| 359 | end | |
| 360 | end | |
| 361 | ||
| 362 | weldItem = function(rootPart, Item, TheC0, unanchor, ParentItem) | |
| 363 | local cframe = TheC0 or rootPart.CFrame:toObjectSpace(Item.CFrame) | |
| 364 | local weld = Instance.new("Weld")
| |
| 365 | weld.Name = "Weld" | |
| 366 | weld.Part0 = rootPart | |
| 367 | weld.Part1 = Item | |
| 368 | weld.C0 = cframe | |
| 369 | weld.Parent = ParentItem and Item or rootPart | |
| 370 | ||
| 371 | if unanchor then | |
| 372 | Item.Anchored = false | |
| 373 | end | |
| 374 | return weld, cframe | |
| 375 | end | |
| 376 | ||
| 377 | scaleModel = function(model, scale) | |
| 378 | local parts = {}
| |
| 379 | local function recurse(object) | |
| 380 | if object:IsA("BasePart") then
| |
| 381 | table.insert(parts, object) | |
| 382 | end | |
| 383 | for _,child in pairs(object:GetChildren()) do | |
| 384 | recurse(child) | |
| 385 | end | |
| 386 | end | |
| 387 | recurse(model) | |
| 388 | ||
| 389 | local top, bottom, left, right, back, front | |
| 390 | for _, part in pairs(parts) do | |
| 391 | if top == nil or top < part.Position.y then top = part.Position.y end | |
| 392 | if bottom == nil or bottom > part.Position.y then bottom = part.Position.y end | |
| 393 | if left == nil or left > part.Position.x then left = part.Position.x end | |
| 394 | if right == nil or right < part.Position.x then right = part.Position.x end | |
| 395 | if back == nil or back > part.Position.z then back = part.Position.z end | |
| 396 | if front == nil or front < part.Position.z then front = part.Position.z end | |
| 397 | end | |
| 398 | ||
| 399 | local middle = Vector3.new( left+right, top+bottom, back+front )/2 | |
| 400 | local minSize = Vector3.new(0.2, 0.2, 0.2) | |
| 401 | ||
| 402 | for _, part in pairs(parts) do | |
| 403 | local foo = part.CFrame.p - middle | |
| 404 | local rotation = part.CFrame - part.CFrame.p | |
| 405 | local newSize = part.Size*scale | |
| 406 | part.FormFactor = "Custom" | |
| 407 | part.Size = newSize | |
| 408 | part.CFrame = CFrame.new( middle + foo*scale ) * rotation | |
| 409 | ||
| 410 | if newSize.x < minSize.x or newSize.y < minSize.y or newSize.z < minSize.z then | |
| 411 | local mesh | |
| 412 | for _, child in pairs(part:GetChildren()) do | |
| 413 | if child:IsA("DataModelMesh") then
| |
| 414 | mesh = child | |
| 415 | break | |
| 416 | end | |
| 417 | end | |
| 418 | ||
| 419 | if mesh == nil then | |
| 420 | mesh = Instance.new("BlockMesh", part)
| |
| 421 | end | |
| 422 | ||
| 423 | local oScale = mesh.Scale | |
| 424 | local newScale = newSize/minSize * oScale | |
| 425 | if 0.2 < newSize.x then newScale = Vector3.new(1 * oScale.x, newScale.y, newScale.z) end | |
| 426 | if 0.2 < newSize.y then newScale = Vector3.new(newScale.x, 1 * oScale.y, newScale.z) end | |
| 427 | if 0.2 < newSize.z then newScale = Vector3.new(newScale.x, newScale.y, 1 * oScale.z) end | |
| 428 | ||
| 429 | mesh.Scale = newScale | |
| 430 | end | |
| 431 | end | |
| 432 | end | |
| 433 | ||
| 434 | function getMass(Obj, Total) | |
| 435 | local newTotal = Total | |
| 436 | local returnTotal = 0 | |
| 437 | ||
| 438 | if Obj:IsA("BasePart") then
| |
| 439 | newTotal = newTotal + Objects[Obj] | |
| 440 | elseif BodyObjects[Obj.ClassName] then | |
| 441 | Obj:Destroy() | |
| 442 | end | |
| 443 | ||
| 444 | if Obj:GetChildren() and #Obj:GetChildren() > 0 then | |
| 445 | for _,v in pairs(Obj:GetChildren()) do | |
| 446 | returnTotal = returnTotal + getMass(v, newTotal) | |
| 447 | end | |
| 448 | else | |
| 449 | returnTotal = newTotal | |
| 450 | end | |
| 451 | ||
| 452 | return returnTotal | |
| 453 | end | |
| 454 | ||
| 455 | function getTargFromCurrent() | |
| 456 | local Current = Current.Part | |
| 457 | if Current:IsA("BasePart") then
| |
| 458 | return Current | |
| 459 | elseif Current:findFirstChild("Torso") then
| |
| 460 | return Current.Torso | |
| 461 | else | |
| 462 | for _,v in pairs(Current:GetChildren()) do | |
| 463 | if v:IsA("BasePart") then
| |
| 464 | return v | |
| 465 | end | |
| 466 | end | |
| 467 | end | |
| 468 | end | |
| 469 | ||
| 470 | function Fire(Part, Vec, Inv) | |
| 471 | pcall(function() | |
| 472 | Current.BP:Destroy() | |
| 473 | Current.BP = nil | |
| 474 | end) | |
| 475 | pcall(function() | |
| 476 | Current.BA:Destroy() | |
| 477 | Current.BA = nil | |
| 478 | end) | |
| 479 | pcall(function() | |
| 480 | if Inv then | |
| 481 | Part.Velocity = -((Vec - Torso.Position).unit * Grav * 1.1) | |
| 482 | else | |
| 483 | Part.Velocity = ((Vec - Camera.CoordinateFrame.p).unit * Grav * 1.1) | |
| 484 | end | |
| 485 | Current.Mass = nil | |
| 486 | end) | |
| 487 | Reset() | |
| 488 | end | |
| 489 | ||
| 490 | function Reset() | |
| 491 | LS.Parent = nil | |
| 492 | RS.Parent = nil | |
| 493 | ||
| 494 | OrigLS.Parent = Torso | |
| 495 | OrigRS.Parent = Torso | |
| 496 | ||
| 497 | OrigLS.C0 = LS0 | |
| 498 | OrigRS.C0 = RS0 | |
| 499 | end | |
| 500 | ||
| 501 | function Start() | |
| 502 | Cor(function() | |
| 503 | repeat wait(1/30) until LP.Character and LP.Character.Parent == Workspace and LP.Character:findFirstChild("Torso")
| |
| 504 | Char = LP.Character | |
| 505 | PlrGui = LP.PlayerGui | |
| 506 | Backpack = LP.Backpack | |
| 507 | Mouse = LP:GetMouse() | |
| 508 | ||
| 509 | for _,v in pairs(Cons) do | |
| 510 | v:disconnect() | |
| 511 | end | |
| 512 | Cons = {}
| |
| 513 | ||
| 514 | Camera = Workspace.CurrentCamera | |
| 515 | LastCamCF = Camera.CoordinateFrame | |
| 516 | AnimJoints = {}
| |
| 517 | mDown = false | |
| 518 | Multi = false | |
| 519 | Grabbing = false | |
| 520 | Current = {}
| |
| 521 | Alpha = 1 | |
| 522 | ||
| 523 | Head = Char["Head"] | |
| 524 | Torso = Char["Torso"] | |
| 525 | Humanoid = Char["Humanoid"] | |
| 526 | LA = Char["Left Arm"] | |
| 527 | RA = Char["Right Arm"] | |
| 528 | LL = Char["Left Leg"] | |
| 529 | RL = Char["Right Leg"] | |
| 530 | ||
| 531 | OrigLS = Torso["Left Shoulder"] | |
| 532 | OrigRS = Torso["Right Shoulder"] | |
| 533 | ||
| 534 | for _,v in pairs(Char:GetChildren()) do | |
| 535 | if v.Name == ModID then | |
| 536 | v:Destroy() | |
| 537 | end | |
| 538 | end | |
| 539 | ||
| 540 | for _,v in pairs(PlrGui:GetChildren()) do | |
| 541 | if v.Name == "PadsGui" then | |
| 542 | v:Destroy() | |
| 543 | end | |
| 544 | end | |
| 545 | ||
| 546 | LS = Instance.new("Weld")
| |
| 547 | RS = Instance.new("Weld")
| |
| 548 | ||
| 549 | LS.Name = OrigLS.Name | |
| 550 | LS.Part0 = Torso | |
| 551 | LS.Part1 = LA | |
| 552 | LS.C0 = LS0 | |
| 553 | LS.C1 = CFrame.new(0, 0.5, 0, 1, 0, 0, 0, 0, 1, 0, -1, 0) | |
| 554 | ||
| 555 | RS.Name = OrigRS.Name | |
| 556 | RS.Part0 = Torso | |
| 557 | RS.Part1 = RA | |
| 558 | RS.C0 = RS0 | |
| 559 | RS.C1 = CFrame.new(0, 0.5, 0, 1, 0, 0, 0, 0, 1, 0, -1, 0) | |
| 560 | ||
| 561 | local Pads = MakePads() | |
| 562 | local LPad = Pads.LBase | |
| 563 | local RPad = Pads.RBase | |
| 564 | ||
| 565 | weldModel(LPad, true, LPad) | |
| 566 | weldModel(RPad, true, RPad) | |
| 567 | ||
| 568 | local GripWeldL = Instance.new("Weld")
| |
| 569 | GripWeldL.Name = "GripWeldL" | |
| 570 | GripWeldL.Part0 = LA | |
| 571 | GripWeldL.Part1 = LPad | |
| 572 | GripWeldL.C0 = CFrame.new(0, -1.05, 0) * CFrame.Angles(0, math.rad(180), 0) | |
| 573 | GripWeldL.Parent = LA | |
| 574 | ||
| 575 | local GripWeldR = Instance.new("Weld")
| |
| 576 | GripWeldR.Name = "GripWeldR" | |
| 577 | GripWeldR.Part0 = RA | |
| 578 | GripWeldR.Part1 = RPad | |
| 579 | GripWeldR.C0 = CFrame.new(0, -1.05, 0) * CFrame.Angles(0, math.rad(180), 0) | |
| 580 | GripWeldR.Parent = RA | |
| 581 | ||
| 582 | local isParts = false | |
| 583 | ||
| 584 | table.insert(Cons, Mouse.KeyDown:connect(function(Key) | |
| 585 | Key = Key:lower() | |
| 586 | if Key == "z" then | |
| 587 | --Stuff | |
| 588 | elseif Key == "f" then | |
| 589 | local Current = Current.Part | |
| 590 | if Current and Current.Parent ~= nil and not Multi then | |
| 591 | Current:BreakJoints() | |
| 592 | end | |
| 593 | elseif Key == "q" then | |
| 594 | if isParts then | |
| 595 | isParts = false | |
| 596 | for _,v in pairs(Workspace:GetChildren()) do | |
| 597 | if v.Name == "MyPartV" and v:IsA("BasePart") then
| |
| 598 | v:Destroy() | |
| 599 | end | |
| 600 | end | |
| 601 | else | |
| 602 | isParts = true | |
| 603 | for i = 1, 50 do | |
| 604 | local Part = Instance.new("Part")
| |
| 605 | Part.Color = Color3.new(math.random(), math.random(), math.random()) | |
| 606 | Part.Transparency = 0 | |
| 607 | Part.Size = Vector3.new(math.random(1, 3), math.random(1, 3), math.random(1, 3)) | |
| 608 | Part.Archivable = true | |
| 609 | Part.CanCollide = false | |
| 610 | Part.Material = "Neon" | |
| 611 | Part.Locked = false | |
| 612 | Part.CFrame = Torso.CFrame * CFrame.new(math.random(-15, 15), -1, math.random(-15, 15)) | |
| 613 | Part.Anchored = true | |
| 614 | Part.Name = "MyPartV" | |
| 615 | Part.TopSurface = "Smooth" | |
| 616 | Part.BottomSurface = "Smooth" | |
| 617 | Part.Parent = Workspace | |
| 618 | end | |
| 619 | end | |
| 620 | elseif Key == "e" then | |
| 621 | local Targ; | |
| 622 | if Current.Part and Current.Part ~= nil then | |
| 623 | Targ = getTargFromCurrent() | |
| 624 | else | |
| 625 | Targ = LastPart | |
| 626 | end | |
| 627 | if Targ and Targ.Parent ~= nil and not Multi then | |
| 628 | local Ex = Instance.new("Explosion", Workspace)
| |
| 629 | Ex.Position = Targ.CFrame.p | |
| 630 | Ex.BlastRadius = 16 | |
| 631 | Ex.DestroyJointRadiusPercent = 0.5 | |
| 632 | end | |
| 633 | elseif Key == "c" then | |
| 634 | if Current.Part and Current.Part.Parent ~= nil and not Multi then | |
| 635 | local Part = getTargFromCurrent() | |
| 636 | if Part then | |
| 637 | Grabbing = false | |
| 638 | if Mouse.Hit then | |
| 639 | local TargPos = CFrame.new(Camera.CoordinateFrame.p, Mouse.Hit.p) * CFrame.new(0, 0, -1000) | |
| 640 | Fire(Part, TargPos.p) | |
| 641 | else | |
| 642 | Fire(Part, Mouse.Origin.p + Mouse.UnitRay.Direction, true) | |
| 643 | end | |
| 644 | end | |
| 645 | end | |
| 646 | end | |
| 647 | end)) | |
| 648 | ||
| 649 | table.insert(Cons, Mouse.Button1Up:connect(function() | |
| 650 | mDown = false | |
| 651 | if Grabbing == true and Multi == false then | |
| 652 | Grabbing = false | |
| 653 | Reset() | |
| 654 | end | |
| 655 | if Current.Part ~= nil then | |
| 656 | LastPart = getTargFromCurrent() | |
| 657 | Current = {}
| |
| 658 | end | |
| 659 | end)) | |
| 660 | ||
| 661 | local function makeLightning(Par, Start, End, Width, Length, RandomScale, ArcScale, Num1) | |
| 662 | local oldParts = {}
| |
| 663 | for _,v in pairs(Par:GetChildren()) do | |
| 664 | v.CFrame = CFrame.new(5e5, 5e5, 5e5) | |
| 665 | table.insert(oldParts, v) | |
| 666 | end | |
| 667 | local Distance = (Start-End).Magnitude | |
| 668 | local ArcScale = ArcScale or 1 | |
| 669 | local RandomScale = RandomScale or 0 | |
| 670 | local Last = Start | |
| 671 | local IterNum = 0 | |
| 672 | ||
| 673 | while Par.Parent do | |
| 674 | IterNum = IterNum + 1 | |
| 675 | local New = nil | |
| 676 | if (Last-End).Magnitude < Length then | |
| 677 | New = CFrame.new(End) | |
| 678 | else | |
| 679 | if (End-Last).Magnitude < Length*2 then | |
| 680 | RandomScale = RandomScale*0.5 | |
| 681 | ArcScale = ArcScale*0.5 | |
| 682 | end | |
| 683 | - | local Direct = CFrame.new(Last,End) |
| 683 | + | |
| 684 | - | New = Direct*CFrame.Angles(math.rad(math.random(-RandomScale/4,RandomScale*ArcScale)),math.rad(math.random(-RandomScale,RandomScale)),math.rad(math.random(-RandomScale,RandomScale))) |
| 684 | + | |
| 685 | - | New = New*CFrame.new(0,0,-Length) |
| 685 | + | |
| 686 | Hum = v.Humanoid | |
| 687 | - | local Trail = nil |
| 687 | + | |
| 688 | - | if oldParts[IterNum] then |
| 688 | + | |
| 689 | - | Trail = oldParts[IterNum] |
| 689 | + | |
| 690 | - | Trail.BrickColor = ((Num1 % 2 == 0) and BrickColor.new("Persimmon")) or BrickColor.new("Really red")
|
| 690 | + | |
| 691 | - | Trail.Size = Vector3.new(Width, (Last-New.p).Magnitude, Width) |
| 691 | + | |
| 692 | - | Trail.CFrame = CFrame.new(New.p, Last)*CFrame.Angles(math.rad(90),0,0)*CFrame.new(0, -(Last-New.p).Magnitude/2, 0) |
| 692 | + | |
| 693 | - | oldParts[IterNum] = nil |
| 693 | + | |
| 694 | ||
| 695 | - | Trail = Instance.new("Part")
|
| 695 | + | |
| 696 | - | Trail.Name = "Part" |
| 696 | + | |
| 697 | - | Trail.FormFactor = "Custom" |
| 697 | + | |
| 698 | - | Trail.BrickColor = ((Num1 % 2 == 0) and BrickColor.new("White")) or BrickColor.new("White")
|
| 698 | + | |
| 699 | - | Trail.Transparency = 0 |
| 699 | + | |
| 700 | - | Trail.Anchored = true |
| 700 | + | |
| 701 | - | Trail.CanCollide = false |
| 701 | + | |
| 702 | - | Trail.Locked = true |
| 702 | + | |
| 703 | - | Trail.BackSurface = "SmoothNoOutlines" |
| 703 | + | |
| 704 | - | Trail.BottomSurface = "SmoothNoOutlines" |
| 704 | + | |
| 705 | - | Trail.FrontSurface = "SmoothNoOutlines" |
| 705 | + | |
| 706 | - | Trail.LeftSurface = "SmoothNoOutlines" |
| 706 | + | |
| 707 | - | Trail.RightSurface = "SmoothNoOutlines" |
| 707 | + | |
| 708 | - | Trail.TopSurface = "SmoothNoOutlines" |
| 708 | + | |
| 709 | - | Trail.Material = "Neon" |
| 709 | + | |
| 710 | - | Trail.Size = Vector3.new(Width, (Last-New.p).Magnitude, Width) |
| 710 | + | |
| 711 | - | Trail.CFrame = CFrame.new(New.p, Last)*CFrame.Angles(math.rad(90),0,0)*CFrame.new(0, -(Last-New.p).Magnitude/2, 0) |
| 711 | + | |
| 712 | - | Trail.Parent = Par |
| 712 | + | |
| 713 | OrigLS.Parent = nil | |
| 714 | - | Last = New.p |
| 714 | + | |
| 715 | - | if (Last-End).Magnitude < 1 then |
| 715 | + | |
| 716 | LS.Parent = Torso | |
| 717 | RS.Parent = Torso | |
| 718 | ||
| 719 | - | for _,v in pairs(oldParts) do |
| 719 | + | |
| 720 | RS.C0 = RS0 | |
| 721 | ||
| 722 | local DirDot = Mouse.UnitRay.Direction:Dot(Targ.Position - Mouse.Origin.p) | |
| 723 | local BPPos = Vector3.new(0, 0, 0) | |
| 724 | - | table.insert(Cons, Mouse.Button1Down:connect(function() |
| 724 | + | |
| 725 | - | mDown = true |
| 725 | + | |
| 726 | - | local Targ = Mouse.Target |
| 726 | + | |
| 727 | - | Cor(function() |
| 727 | + | |
| 728 | - | if Targ and Objects[Targ] and not Multi then |
| 728 | + | |
| 729 | - | Grabbing = true |
| 729 | + | |
| 730 | - | Current.Part = Targ |
| 730 | + | |
| 731 | - | local Mass = Objects[Targ] |
| 731 | + | |
| 732 | - | local ForceNum = 0 |
| 732 | + | |
| 733 | - | local Hum = nil |
| 733 | + | |
| 734 | Ball.CanCollide = false | |
| 735 | - | for _,v in pairs(Targ:GetChildren()) do |
| 735 | + | |
| 736 | - | if BodyObjects[v.ClassName] then |
| 736 | + | |
| 737 | Ball.Size = Vector3.new(0.5, 0.5, 0.5) | |
| 738 | Ball.CFrame = Torso.CFrame * CFrame.new(0, 1, -3) | |
| 739 | Ball.Parent = Char | |
| 740 | ||
| 741 | if Targ.Name == "MyPartV" then | |
| 742 | Targ.Name = "MyPartF" | |
| 743 | end | |
| 744 | ||
| 745 | local LightMod = Instance.new("Model", Char)
| |
| 746 | ||
| 747 | local Mesh = Instance.new("SpecialMesh")
| |
| 748 | Mesh.MeshType = "Sphere" | |
| 749 | Mesh.Parent = Ball | |
| 750 | ||
| 751 | local Size = 0.5 | |
| 752 | local Rise = true | |
| 753 | ||
| 754 | while Grabbing and BP and Ang and Targ.Parent ~= nil do | |
| 755 | local BPPos = Mouse.Origin.p + Mouse.UnitRay.Direction * DirDot | |
| 756 | Ang.angularvelocity = Vel | |
| 757 | BP.position = BPPos + RPos | |
| 758 | RPos = Vector3.new(max(-1, min(RPos.x + random() * 0.02 - 0.01, 1)), cos(Vlev), max(-1, min(RPos.z + random() * 0.02 - 0.01, 1))) | |
| 759 | Vel = Vector3.new(max(-1, min(Vel.x + random() * 0.2 - 0.1, 1)), max(-1, min(Vel.y + random() * 0.2 - 0.1, 1)), max(-1, min(Vel.z + random() * 0.2 - 0.1, 1))) | |
| 760 | Vlev = (Vlev + 0.05) % tau | |
| 761 | ||
| 762 | if Hum then | |
| 763 | Hum.Sit = true | |
| 764 | end | |
| 765 | ||
| 766 | if LA.Parent ~= nil and RA.Parent ~= nil then | |
| 767 | local LPos = (LA.CFrame * CFrame.new(0, -1, 0)).p | |
| 768 | local RPos = (RA.CFrame * CFrame.new(0, -1, 0)).p | |
| 769 | if Rise == true then | |
| 770 | if Size < 0.6 then | |
| 771 | Size = Size + 0.05 | |
| 772 | else | |
| 773 | Size = Size + 0.1 | |
| 774 | end | |
| 775 | if Size >= 2.2 then | |
| 776 | Rise = false | |
| 777 | end | |
| 778 | else | |
| 779 | if Size > 2.1 then | |
| 780 | Size = Size - 0.05 | |
| 781 | else | |
| 782 | Size = Size - 0.1 | |
| 783 | end | |
| 784 | if Size <= 0.5 then | |
| 785 | Rise = true | |
| 786 | end | |
| 787 | end | |
| 788 | Ball.Size = Vector3.new(Size, Size, Size) | |
| 789 | Ball.CFrame = CFrame.new(LPos:Lerp(RPos, 0.5), Targ.Position) * CFrame.new(0, 0, -2.2) | |
| 790 | LightNum = LightNum + 1 | |
| 791 | makeLightning(LightMod, Ball.Position, Targ.Position, 0.2, 4, 50, 1, LightNum) | |
| 792 | elseif Ball.Parent ~= nil then | |
| 793 | Ball:Destroy() | |
| 794 | end | |
| 795 | ||
| 796 | if LS and LS.Parent == Torso then | |
| 797 | LS.C0 = CFrame.new(Vector3.new(-1.5, 0.5, 0), Torso.CFrame:pointToObjectSpace((Targ.CFrame or Torso.CFrame * CFrame.new(-1.5, 0.5, 1)).p)) | |
| 798 | end | |
| 799 | if RS and RS.Parent == Torso then | |
| 800 | RS.C0 = CFrame.new(Vector3.new(1.5, 0.5, 0), Torso.CFrame:pointToObjectSpace((Targ.CFrame or Torso.CFrame * CFrame.new(1.5, 0.5, 1)).p)) | |
| 801 | end | |
| 802 | RunService.Heartbeat:wait() | |
| 803 | end | |
| 804 | ||
| 805 | coroutine.resume(coroutine.create(function() | |
| 806 | for i = 0.5, 1, 0.1 do | |
| 807 | for i2,v in pairs(LightMod:GetChildren()) do | |
| 808 | --v.Light.Range = 6-(i*5) | |
| 809 | v.Transparency = i | |
| 810 | end | |
| 811 | wait(1/30) | |
| 812 | end | |
| 813 | LightMod:Destroy() | |
| 814 | end)) | |
| 815 | ||
| 816 | if BP and BP.Parent ~= nil then | |
| 817 | BP:Destroy() | |
| 818 | end | |
| 819 | ||
| 820 | if Ang and Ang.Parent ~= nil then | |
| 821 | Ang:Destroy() | |
| 822 | end | |
| 823 | ||
| 824 | pcall(function() Ball:Destroy() end) | |
| 825 | end | |
| 826 | end) | |
| 827 | end)) | |
| 828 | end) | |
| 829 | end | |
| 830 | ||
| 831 | function Add(Obj) | |
| 832 | if Obj:IsA("BasePart") and not Objects[Obj] and not (Obj.Name == "Base" and Obj.ClassName == "Part") then
| |
| 833 | Objects[Obj] = Obj:GetMass() | |
| 834 | Obj.Changed:connect(function(P) | |
| 835 | if P:lower() == "size" and Objects[Obj] and Obj.Parent ~= nil then | |
| 836 | Objects[Obj] = Obj:GetMass() | |
| 837 | end | |
| 838 | end) | |
| 839 | end | |
| 840 | end | |
| 841 | ||
| 842 | function Rem(Obj) | |
| 843 | if Objects[Obj] then | |
| 844 | Objects[Obj] = nil | |
| 845 | end | |
| 846 | end | |
| 847 | ||
| 848 | function Recursion(Obj) | |
| 849 | ypcall(function() | |
| 850 | Add(Obj) | |
| 851 | if #Obj:GetChildren() > 0 then | |
| 852 | for _,v in pairs(Obj:GetChildren()) do | |
| 853 | Recursion(v) | |
| 854 | end | |
| 855 | end | |
| 856 | end) | |
| 857 | end | |
| 858 | ||
| 859 | Workspace.DescendantAdded:connect(function(Obj) | |
| 860 | Add(Obj) | |
| 861 | end) | |
| 862 | ||
| 863 | Workspace.DescendantRemoving:connect(function(Obj) | |
| 864 | Rem(Obj) | |
| 865 | end) | |
| 866 | ||
| 867 | for _,v in pairs(Workspace:GetChildren()) do | |
| 868 | Recursion(v) | |
| 869 | end | |
| 870 | ||
| 871 | Start() | |
| 872 | ||
| 873 | if LP.Name == PlrName then | |
| 874 | LP.CharacterAdded:connect(Start) | |
| 875 | end | |
| 876 | ||
| 877 | local verlet = {}
| |
| 878 | verlet.step_time = 1 / 50 | |
| 879 | verlet.gravity = Vector3.new(0, -10, 0) | |
| 880 | ||
| 881 | local char = game.Players.LocalPlayer.Character | |
| 882 | local torso = char:WaitForChild("Torso")
| |
| 883 | local parts = {}
| |
| 884 | local render = game:GetService("RunService").RenderStepped
| |
| 885 | ||
| 886 | wait(2) | |
| 887 | ||
| 888 | local point = {}
| |
| 889 | local link = {}
| |
| 890 | local rope = {}
| |
| 891 | ||
| 892 | local function ccw(A,B,C) | |
| 893 | return (C.y-A.y) * (B.x-A.x) > (B.y-A.y) * (C.x-A.x) | |
| 894 | end | |
| 895 | ||
| 896 | local function intersect(A,B,C,D) | |
| 897 | return ccw(A,C,D) ~= ccw(B,C,D) and ccw(A,B,C) ~= ccw(A,B,D) | |
| 898 | end | |
| 899 | ||
| 900 | local function vec2(v) | |
| 901 | return Vector2.new(v.x, v.z) | |
| 902 | end | |
| 903 | ||
| 904 | function point:step() | |
| 905 | if not self.fixed then | |
| 906 | local derivative = (self.position - self.last_position) * 0.95 | |
| 907 | self.last_position = self.position | |
| 908 | self.position = self.position + derivative + (self.velocity * verlet.step_time ^ 2) | |
| 909 | --[[local torsoP = torso.CFrame * CFrame.new(-1, 0, 0.5) | |
| 910 | local torsoE = torso.CFrame * CFrame.new(1, 0, 0.5) | |
| 911 | local pointE = self.position + torso.CFrame.lookVector * 100 | |
| 912 | local doIntersect = intersect(vec2(torsoP.p), vec2(torsoE.p), vec2(self.position), vec2(pointE)) | |
| 913 | if not doIntersect then | |
| 914 | self.postition = self.position - torso.CFrame.lookVector * 10 | |
| 915 | end]] | |
| 916 | end | |
| 917 | end | |
| 918 | ||
| 919 | function link:step() | |
| 920 | for i = 1, 1 do | |
| 921 | local distance = self.point1.position - self.point2.position | |
| 922 | local magnitude = distance.magnitude | |
| 923 | local differance = (self.length - magnitude) / magnitude | |
| 924 | local translation = ((self.point1.fixed or self.point2.fixed) and 1 or 0.6) * distance * differance | |
| 925 | if not self.point1.fixed then | |
| 926 | self.point1.position = self.point1.position + translation | |
| 927 | end | |
| 928 | if not self.point2.fixed then | |
| 929 | self.point2.position = self.point2.position - translation | |
| 930 | end | |
| 931 | end | |
| 932 | end | |
| 933 | ||
| 934 | function verlet.new(class, a, b, c) | |
| 935 | if class == "Point" then | |
| 936 | local new = {}
| |
| 937 | setmetatable(new, {__index = point})
| |
| 938 | new.class = class | |
| 939 | new.position = a or Vector3.new() | |
| 940 | new.last_position = new.position | |
| 941 | new.velocity = verlet.gravity | |
| 942 | new.fixed = false | |
| 943 | return new | |
| 944 | elseif class == "Link" then | |
| 945 | local new = {}
| |
| 946 | setmetatable(new, {__index = link})
| |
| 947 | new.class = class | |
| 948 | new.point1 = a | |
| 949 | new.point2 = b | |
| 950 | new.length = c or (a.position - b.position).magnitude | |
| 951 | return new | |
| 952 | elseif class == "Rope" then | |
| 953 | local new = {}
| |
| 954 | setmetatable(new, {__index = link})
| |
| 955 | new.class = class | |
| 956 | new.start_point = a | |
| 957 | new.finish_point = b | |
| 958 | new.points = {}
| |
| 959 | new.links = {}
| |
| 960 | local inc = (b - a) / 10 | |
| 961 | for i = 0, 10 do | |
| 962 | table.insert(new.points, verlet.new("Point", a + (i * inc)))
| |
| 963 | end | |
| 964 | for i = 2, #new.points do | |
| 965 | table.insert(new.links, verlet.new("Link", new.points[i - 1], new.points[i]))
| |
| 966 | end | |
| 967 | return new | |
| 968 | end | |
| 969 | end | |
| 970 | ||
| 971 | local tris = {}
| |
| 972 | local triParts = {}
| |
| 973 | ||
| 974 | local function GetDiscoColor(hue) | |
| 975 | local section = hue % 1 * 3 | |
| 976 | local secondary = 0.5 * math.pi * (section % 1) | |
| 977 | if section < 1 then | |
| 978 | return Color3.new(0, 0, 0) | |
| 979 | elseif section < 2 then | |
| 980 | return Color3.new(0, 0, 0) | |
| 981 | else | |
| 982 | return Color3.new(0, 0, 0) | |
| 983 | end | |
| 984 | end | |
| 985 | ||
| 986 | local function setupPart(part) | |
| 987 | part.Anchored = true | |
| 988 | part.FormFactor = 3 | |
| 989 | part.CanCollide = false | |
| 990 | part.TopSurface = 10 | |
| 991 | part.BottomSurface = 10 | |
| 992 | part.LeftSurface = 10 | |
| 993 | part.RightSurface = 10 | |
| 994 | part.FrontSurface = 10 | |
| 995 | part.BackSurface = 10 | |
| 996 | part.Material = "Neon" | |
| 997 | local m = Instance.new("SpecialMesh", part)
| |
| 998 | m.MeshType = "Wedge" | |
| 999 | m.Scale = Vector3.new(0.2, 1, 1) | |
| 1000 | return part | |
| 1001 | end | |
| 1002 | ||
| 1003 | local function CFrameFromTopBack(at, top, back) | |
| 1004 | local right = top:Cross(back) | |
| 1005 | return CFrame.new(at.x, at.y, at.z, right.x, top.x, back.x, right.y, top.y, back.y, right.z, top.z, back.z) | |
| 1006 | end | |
| 1007 | ||
| 1008 | local function drawTri(parent, a, b, c) | |
| 1009 | local this = {}
| |
| 1010 | local mPart1 = table.remove(triParts, 1) or setupPart(Instance.new("Part"))
| |
| 1011 | local mPart2 = table.remove(triParts, 1) or setupPart(Instance.new("Part"))
| |
| 1012 | function this:Set(a, b, c) | |
| 1013 | local ab, bc, ca = b-a, c-b, a-c | |
| 1014 | local abm, bcm, cam = ab.magnitude, bc.magnitude, ca.magnitude | |
| 1015 | local edg1 = math.abs(0.5 + ca:Dot(ab)/(abm*abm)) | |
| 1016 | local edg2 = math.abs(0.5 + ab:Dot(bc)/(bcm*bcm)) | |
| 1017 | local edg3 = math.abs(0.5 + bc:Dot(ca)/(cam*cam)) | |
| 1018 | if edg1 < edg2 then | |
| 1019 | if edg1 >= edg3 then | |
| 1020 | a, b, c = c, a, b | |
| 1021 | ab, bc, ca = ca, ab, bc | |
| 1022 | abm = cam | |
| 1023 | end | |
| 1024 | else | |
| 1025 | if edg2 < edg3 then | |
| 1026 | a, b, c = b, c, a | |
| 1027 | ab, bc, ca = bc, ca, ab | |
| 1028 | abm = bcm | |
| 1029 | else | |
| 1030 | a, b, c = c, a, b | |
| 1031 | ab, bc, ca = ca, ab, bc | |
| 1032 | abm = cam | |
| 1033 | end | |
| 1034 | end | |
| 1035 | ||
| 1036 | local len1 = -ca:Dot(ab)/abm | |
| 1037 | local len2 = abm - len1 | |
| 1038 | local width = (ca + ab.unit*len1).magnitude | |
| 1039 | ||
| 1040 | local maincf = CFrameFromTopBack(a, ab:Cross(bc).unit, -ab.unit) | |
| 1041 | ||
| 1042 | if len1 > 0.2 then | |
| 1043 | mPart1.Parent = parent | |
| 1044 | mPart1.Size = Vector3.new(0.2, width, len1) | |
| 1045 | mPart1.CFrame = maincf*CFrame.Angles(math.pi,0,math.pi/2)*CFrame.new(0,width/2,len1/2) | |
| 1046 | else | |
| 1047 | mPart1.Parent = nil | |
| 1048 | end | |
| 1049 | ||
| 1050 | if len2 > 0.2 then | |
| 1051 | mPart2.Parent = parent | |
| 1052 | mPart2.Size = Vector3.new(0.2, width, len2) | |
| 1053 | mPart2.CFrame = maincf*CFrame.Angles(math.pi,math.pi,-math.pi/2)*CFrame.new(0,width/2,-len1 - len2/2) | |
| 1054 | else | |
| 1055 | mPart2.Parent = nil | |
| 1056 | end | |
| 1057 | end | |
| 1058 | function this:SetProperty(prop, value) | |
| 1059 | mPart1[prop] = value | |
| 1060 | mPart2[prop] = value | |
| 1061 | end | |
| 1062 | this:Set(a, b, c) | |
| 1063 | function this:Destroy() | |
| 1064 | mPart1:Destroy() | |
| 1065 | mPart2:Destroy() | |
| 1066 | end | |
| 1067 | this.p1 = mPart1 | |
| 1068 | this.p2 = mPart2 | |
| 1069 | this.p1.BrickColor = BrickColor.new(GetDiscoColor(math.noise(0.5, 0.5, this.p1.CFrame.Y * 0.5 + time()))) | |
| 1070 | this.p2.BrickColor = BrickColor.new(GetDiscoColor(math.noise(0.5, 0.5, this.p2.CFrame.Y * 0.5 + time()))) | |
| 1071 | return this | |
| 1072 | end | |
| 1073 | ||
| 1074 | function verlet.draw(object, id) | |
| 1075 | if object.class == "Point" then | |
| 1076 | local part = parts[id] | |
| 1077 | part.BrickColor = BrickColor.new(255, 0, 0) | |
| 1078 | part.Transparency = 0 | |
| 1079 | part.formFactor = 3 | |
| 1080 | part.Anchored = true | |
| 1081 | part.CanCollide = false | |
| 1082 | part.TopSurface = 0 | |
| 1083 | part.BottomSurface = 0 | |
| 1084 | part.Size = Vector3.new(0.35, 0.35, 0.35) | |
| 1085 | part.Material = "Neon" | |
| 1086 | part.CFrame = CFrame.new(object.position) | |
| 1087 | part.Parent = torso | |
| 1088 | return part | |
| 1089 | elseif object.class == "Link" then | |
| 1090 | local part = parts[id] | |
| 1091 | local dist = (object.point1.position - object.point2.position).magnitude | |
| 1092 | part.Size = Vector3.new(0.2, 0.2, dist) | |
| 1093 | part.CFrame = CFrame.new(object.point1.position, object.point2.position) * CFrame.new(0, 0, dist * -0.5) | |
| 1094 | part.Parent = torso | |
| 1095 | return part | |
| 1096 | end | |
| 1097 | end | |
| 1098 | ||
| 1099 | function verlet.clear() | |
| 1100 | for _, v in pairs(workspace:GetChildren()) do | |
| 1101 | if v.Name == "Part" then | |
| 1102 | v:Destroy() | |
| 1103 | end | |
| 1104 | end | |
| 1105 | end | |
| 1106 | ||
| 1107 | local points = {}
| |
| 1108 | local links = {}
| |
| 1109 | ||
| 1110 | for x = 0, 2 do | |
| 1111 | points[x] = {}
| |
| 1112 | for y = 0, 3 do | |
| 1113 | points[x][y] = verlet.new("Point", torso.Position + Vector3.new(x * 0.8 - 2, 2 - y * 0.8, 5 + y * 0.4))
| |
| 1114 | points[x][y].fixed = y == 0 | |
| 1115 | end | |
| 1116 | end | |
| 1117 | ||
| 1118 | for x = 1, 2 do | |
| 1119 | for y = 0, 3 do | |
| 1120 | links[#links + 1] = verlet.new("Link", points[x][y], points[x - 1][y], 1 + y * 0.08)
| |
| 1121 | end | |
| 1122 | end | |
| 1123 | ||
| 1124 | for x = 0, 2 do | |
| 1125 | for y = 1, 3 do | |
| 1126 | links[#links + 1] = verlet.new("Link", points[x][y], points[x][y - 1], 1.2 + y * 0.03)
| |
| 1127 | end | |
| 1128 | end | |
| 1129 | ||
| 1130 | render:connect(function() | |
| 1131 | for x = 0, 2 do | |
| 1132 | for y = 0, 3 do | |
| 1133 | if y == 0 then | |
| 1134 | points[x][y].position = (torso.CFrame * CFrame.new(x * 1 - 1, 1, 0.5)).p | |
| 1135 | else | |
| 1136 | points[x][y]:step() | |
| 1137 | end | |
| 1138 | end | |
| 1139 | end | |
| 1140 | for i = 1, #links do | |
| 1141 | links[i]:step() | |
| 1142 | end | |
| 1143 | for i = 1, #tris do | |
| 1144 | triParts[#triParts + 1] = tris[i].p1 | |
| 1145 | triParts[#triParts + 1] = tris[i].p2 | |
| 1146 | end | |
| 1147 | tris = {}
| |
| 1148 | for x = 1, 2 do | |
| 1149 | for y = 1, 3 do | |
| 1150 | tris[#tris + 1] = drawTri(torso, points[x - 1][y - 1].position, points[x - 1][y].position, points[x][y - 1].position) | |
| 1151 | tris[#tris + 1] = drawTri(torso, points[x][y].position, points[x - 1][y].position, points[x][y - 1].position) | |
| 1152 | end | |
| 1153 | end | |
| 1154 | end) |