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