Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Gaster <3
- -- Took Alot Longer Then It Should Have.
- dot = false
- des = false
- local ChatService = game:GetService("Chat")
- local player = game.Players.LocalPlayer
- char = player.Character
- hum = char.Humanoid
- torso = hum.Torso
- m=player:GetMouse()
- bb = Instance.new("BillboardGui",player.Character.Head)
- bb.Enabled = true
- bb.AlwaysOnTop = true
- bb.Size = UDim2.new(0,200,0,50)
- bb.StudsOffset = Vector3.new(0,1,0)
- gui=Instance.new("TextBox",bb)
- gui.Text = "* "
- gui.Size = UDim2.new(0,133,0,45)
- gui.Position=UDim2.new(0,57,0,-40)
- gui.TextColor3 = Color3.new(255,255,255)
- gui.BackgroundColor3=Color3.new(0,0,0)
- gui.TextWrapped = true
- gui.TextScaled = true
- gui.TextXAlignment = "Left"
- gui.TextYAlignment = "Top"
- gui.Visible = false
- gui.BorderColor3 = Color3.new(0,0,0)
- gui1=Instance.new("TextButton",bb)
- gui1.Position=UDim2.new(0,5,0,-43)
- gui1.Size = UDim2.new(0,190,0,51)
- gui1.TextColor3 = Color3.new(255,255,255)
- gui1.BackgroundColor3=Color3.new(255,255,255)
- gui1.Visible = false
- img = Instance.new("ImageLabel",bb)
- img.Size = UDim2.new(0,46,0,47)
- img.Position = UDim2.new(0,10,0,-41)
- img.Image = "rbxassetid://419852216"
- img.BorderColor3 = Color3.new(0,0,0)
- img.Visible = false
- asd = Instance.new("Sound",player.Character.Torso)
- asd.SoundId = "http://www.roblox.com/asset/?id = 419874833"
- asd1 = Instance.new("Sound",player.Character.Torso)
- asd1.SoundId = "http://www.roblox.com/asset/?id = 419874833"
- EpicText = Instance.new("Sound",player.Character.Torso)
- EpicText.SoundId = "http://www.roblox.com/asset/?id = 454824301"
- asd2 = Instance.new("Sound",player.Character.Torso)
- asd2.SoundId = "http://www.roblox.com/asset/?id = 441352248"
- asd2.Looped = true
- asd3 = Instance.new("Sound",player.Character.Torso)
- asd3.SoundId = "http://www.roblox.com/asset/?id = 440709051"
- asd3.Looped = true
- asd4 = Instance.new("Sound",player.Character.Torso)
- asd4.SoundId = "http://www.roblox.com/asset/?id = 304222305"
- asd4.Looped = false
- asd5 = Instance.new("Sound",player.Character.Torso)
- asd5.SoundId = "http://www.roblox.com/asset/?id = 428665016"
- asd5.Looped = true
- dunkd = Instance.new("Sound",player.Character.Torso)
- dunkd.SoundId = "http://www.roblox.com/asset/?id = 318502757"
- dunkd.Looped = false
- function play(play)
- asd:Play()
- asd1:Play()
- end
- eye = Instance.new("Part",player.Character)
- eye.BrickColor = BrickColor.new("Black")
- eye.Material = "Neon"
- eye.FormFactor = 3
- eye.Shape = "Ball"
- eye.Size = Vector3.new(0.37,0.37,0.1)
- weld = Instance.new("Weld",eye)
- weld.Part0 = eye
- weld.Part1 = player.Character.Head
- weld.C0 = CFrame.new(0.1,-0.2,0.45)
- eye.Transparency = 1
- -- listen for their chatting
- player.Chatted:connect(function(message)
- a = string.len(message)
- gui.Text = "* "
- gui.Visible = true
- gui1.Visible = true
- des = false
- img.Visible = true
- print(a)
- if dot == false then
- for i = 1,string.len(message) do wait(0.07)
- gui.Text =gui.Text..message:sub(i,i)
- play()
- end
- end
- des = true
- end)
- m.KeyDown:connect(function(k)
- if k == "l" then
- asd2:Play()
- end
- end)
- m.KeyDown:connect(function(k)
- if k == "k" then
- asd3:Play()
- end
- end)
- m.KeyDown:connect(function(k)
- if k == "j" then
- asd4:Play()
- end
- end)
- m.KeyDown:connect(function(k)
- if k == "p" then
- asd5:Play()
- end
- end)
- m.KeyDown:connect(function(k)
- if k == "z" then
- asd1 = Instance.new("Sound",player.Character.Torso)
- asd1.SoundId = "http://www.roblox.com/asset/?id = 454824301"
- img.Image = "rbxassetid://460973235"
- asd2:Play()
- EpicText:Play()
- EpicText:Play()
- end
- end)
- m.KeyDown:connect(function(k)
- if k == "n" then
- img.Image = "rbxassetid://419852168"
- end
- end)
- m.KeyDown:connect(function(k)
- if k == "b" then
- img.Image = "rbxassetid://419852186"
- end
- end)
- m.KeyDown:connect(function(k)
- if k == "m" then
- img.Image = "rbxassetid://419852203"
- end
- end)
- m.KeyDown:connect(function(k)
- if k == "h" then
- img.Image = "rbxassetid://419852243"
- end
- end)
- m.KeyDown:connect(function(k)
- if k == "x" then
- if des == true then
- gui.Visible = false
- gui.Text = "! "
- gui1.Visible = false
- img.Visible = false
- end
- end
- end)
- m.KeyDown:connect(function(k)
- if k == ";" then
- asd3:Stop()
- asd2:Stop()
- asd4:Stop()
- dunkd:Stop()
- eye.Transparency = 1
- asd5:Stop()
- end
- end)
- m.KeyDown:connect(function(k)
- if k == "y" then
- img.Image = "rbxassetid://419852216"
- end
- end)
- -- my god...
- -- Suck_HiyaThere moves to arizona
- pls=game:GetService'Players';
- rs=game:GetService'RunService';
- uinps=game:GetService'UserInputService';
- lp=pls.LocalPlayer;
- mouse=lp:GetMouse();
- c=lp.Character;
- rayModel=Instance.new('Model',c);
- human=c.Humanoid;
- Cone=nil;
- human.MaxHealth=1000000;
- wait();
- human.Health=1000000;
- c.Health:Destroy();
- Debounces={
- FPS=0;
- isAttacking=false;
- isMoving=false;
- isSprinting=false;
- Debounce=false;
- isTyping=false;
- isJumping=false;
- isFlash=false;
- };
- numLerp=function(start,goal,alpha)
- return(((goal-start)*alpha)+start);
- end;
- CFrameZero=function()
- return CFrame.new(Vector3.new());
- end;
- local function a()
- local t=tick();
- local l=t%1*3;
- local t=.5*math.pi*(l%1);
- if l<1 then
- return Color3.new(1,1-math.cos(t),1-math.sin(t));
- elseif l<2 then
- return Color3.new(1-math.sin(t),1,1-math.cos(t));
- else
- return Color3.new(1-math.cos(t),1-math.sin(t),1);
- end;
- end;
- rad=function(value)
- return math.rad(value);
- end;
- CFAngles=function(Vector)
- return CFrame.Angles(rad(Vector.x),rad(Vector.y),rad(Vector.z));
- end;
- AnimStat={
- lerpSpeed=.2;
- lerpSpeed2=.35;
- lerpTween=0;
- };
- Joints={
- c.HumanoidRootPart.RootJoint;
- c.Torso.Neck;
- c.Torso['Left Shoulder'];
- c.Torso['Right Shoulder'];
- c.Torso['Left Hip'];
- c.Torso['Right Hip'];
- };
- prepareCharacter=function()
- music=Instance.new('Sound',c.HumanoidRootPart);
- music.SoundId='rbxassetid://306154368';
- music.Looped=true;
- music.Volume=.6;
- music2=Instance.new('Sound',c);
- music2.SoundId='rbxassetid://320842828';
- music2.Looped=true;
- music2.Volume=1;
- music3=Instance.new('Sound',c.HumanoidRootPart);
- music3.SoundId='rbxassetid://304222305';
- music3.Looped=true;
- music3.Volume=1;
- music4=Instance.new('Sound',c.HumanoidRootPart);
- music4.SoundId='rbxassetid://428665016';
- music4.Looped=true;
- music4.Volume=1;
- music5=Instance.new('Sound',c.HumanoidRootPart);
- music5.SoundId='rbxassetid://318502757';
- music5.Looped=true;
- music5.Volume=1;
- human.WalkSpeed=0;
- human.JumpPower=0;
- end;
- triWave=function(x)
- local pi2=math.pi/2;
- return math.abs((x/pi2)%4-2)-1;
- end;
- setLerp=function(speed)
- AnimStat.lerpSpeed=speed;
- end;
- setTween=function(tween)
- AnimStat.lerpTween=tween;
- end;
- playSound=function(id,part,vol,pitch)
- local vol=vol or 1;
- local pitch=pitch or 1;
- local x=Instance.new('Sound',part);
- x.Volume=vol;
- x.Pitch=pitch;
- x.SoundId='rbxassetid://'..id;
- spawn(function()
- wait();
- x:Play();
- wait(x.TimeLength+.2);
- x:Destroy();
- end);
- end;
- lerpBoom=function()
- if Cone then
- Cone.CFrame=CFrame.new(c.HumanoidRootPart.CFrame.p,c.HumanoidRootPart.CFrame.p+c.HumanoidRootPart.Velocity)*CFrame.Angles(-math.pi/2,0,0);
- cMesh.Scale=Vector3.new(20,20+c.HumanoidRootPart.Velocity.magnitude/10,20);
- Cone.Transparency=1-c.HumanoidRootPart.Velocity.magnitude/1000;
- else
- Cone=Instance.new('Part',c);
- Cone.Anchored=true;
- Cone.CanCollide=false;
- Cone.Transparency=math.random(50,70)/100;
- Cone.Size=Vector3.new(1,1,1);
- Cone.CFrame=CFrame.new(c.HumanoidRootPart.CFrame.p,c.HumanoidRootPart.CFrame.p+c.HumanoidRootPart.Velocity)*CFrame.Angles(-math.pi/2,0,0);
- cMesh=Instance.new('SpecialMesh',Cone);
- cMesh.MeshId='rbxassetid://1033714';
- cMesh.Scale=Vector3.new(20,50,20);
- end;
- end;
- noBoom=function()
- if Cone then local x=Cone Cone=nil;
- for i=1,20 do
- wait();
- x.Mesh.Scale=x.Mesh.Scale+Vector3.new(-.5,1,-.5);
- x.Transparency=x.Transparency+1/30;
- end;
- end;
- end;
- gasterBlast=function(tCFrame,aimPos,charge)
- local aimTarget;
- if aimPos then
- aimTarget=CFrame.new(tCFrame,aimPos);
- else
- aimTarget=tCFrame;
- end;
- local gast=Instance.new('Part',c);
- gast.Size=Vector3.new(12,.2,12);
- gast.CanCollide=false;
- gast.Anchored=true;
- gast.Transparency=1;
- if charge then
- playSound(400523331,gast,math.random(90,110)/100);
- end;
- wait();
- for i=1,2 do
- local decal=Instance.new('Decal',gast);
- decal.Texture='rbxassetid://401564454';
- if i==1 then
- decal.Face=Enum.NormalId.Top;
- else
- decal.Face=Enum.NormalId.Bottom;
- end;
- end;
- gast.CFrame=CFrame.new(aimTarget.p-Vector3.new(math.sin(tick()*10)*10,20,math.cos(tick()*10)*10));
- spawn(function()
- local tarCFrame=gast.CFrame;
- local isLooping=true;
- spawn(function()
- while rs.RenderStepped:wait()and isLooping do
- gast.CFrame=gast.CFrame:lerp(tarCFrame,.6/(Debounces.FPS/60));
- end;
- end);
- for i=1,30 do
- wait();
- tarCFrame=gast.CFrame:lerp(aimTarget,.24);
- end;
- playSound(340722848,gast,math.random(90,110)/100);
- isLooping=false;
- wait(.08);
- local ray=Ray.new(aimTarget.p,aimTarget.lookVector.unit*999);
- local _,pos=workspace:FindPartOnRay(ray,c);
- local dis=(aimTarget.p-pos).magnitude;
- local rayCFrame=CFrame.new(gast.CFrame.p+(pos-gast.CFrame.p).unit*(dis/2+200),gast.CFrame.p+(pos-gast.CFrame.p).unit*dis*2)*CFrame.Angles(0,math.pi/2,0);
- local rayPart=Instance.new('Part',rayModel);
- rayPart.Material='Neon';
- rayPart.FormFactor='Custom';
- rayPart.Anchored=true;
- rayPart.CanCollide=false;
- rayPart.Color=a();
- rayPart.Shape='Cylinder';
- rayPart.Size=Vector3.new(dis+400,8,8);
- rayPart.CFrame=rayCFrame;
- gast:Destroy();
- end);
- end;
- largegasterBlast=function(tCFrame,aimPos)
- local aimTarget;
- if aimPos then
- aimTarget=CFrame.new(tCFrame,aimPos);
- else
- aimTarget=tCFrame;
- end;
- local gast=Instance.new('Part',c);
- gast.Size=Vector3.new(25,.2,25);
- gast.CanCollide=false;
- gast.Anchored=true;
- gast.Transparency=1;
- playSound(400523331,gast,math.random(85,97)/100);
- wait();
- for i=1,2 do
- local decal=Instance.new('Decal',gast);
- decal.Texture='rbxassetid://401564690';
- if i==1 then
- decal.Face=Enum.NormalId.Top;
- else
- decal.Face=Enum.NormalId.Bottom;
- end;
- end;
- gast.CFrame=CFrame.new(aimTarget.p-Vector3.new(math.sin(tick()*10)*10,20,math.cos(tick()*10)*10));
- spawn(function()
- local tarCFrame=gast.CFrame;
- local isLooping=true;
- spawn(function()
- while rs.RenderStepped:wait()and isLooping do
- gast.CFrame=gast.CFrame:lerp(tarCFrame,.6/(Debounces.FPS/60));
- end;
- end);
- for i=1,40 do
- wait();
- tarCFrame=gast.CFrame:lerp(aimTarget,.18);
- end;
- playSound(340722848,gast,math.random(80,95)/100);
- isLooping=false;
- wait(.08);
- local ray=Ray.new(aimTarget.p,aimTarget.lookVector.unit*999);
- local _,pos=workspace:FindPartOnRay(ray,c);
- local dis=(aimTarget.p-pos).magnitude;
- local rayCFrame=CFrame.new(gast.CFrame.p+(pos-gast.CFrame.p).unit*(dis/2+200),gast.CFrame.p+(pos-gast.CFrame.p).unit*dis*2)*CFrame.Angles(0,math.pi/2,0);
- local rayPart=Instance.new('Part',rayModel);
- rayPart.Material='Neon';
- rayPart.FormFactor='Custom';
- rayPart.Anchored=true;
- rayPart.CanCollide=false;
- rayPart.Shape='Cylinder';
- rayPart.Size=Vector3.new(dis+400,17,17);
- rayPart.CFrame=rayCFrame;
- gast:Destroy();
- end);
- end;
- if Debounces.isAttacking==false and Debounces.isMoving==false and Debounces.Debounce==false and Debounces.isJumping==false then
- setLerp(.8);
- elseif Debounces.isAttacking==false and Debounces.isMoving==true and Debounces.Debounce==false and Debounces.isSprinting==true and Debounces.isJumping==false then
- sine=tick()*28;
- human.WalkSpeed=400;
- lerpBoom();
- setLerp(.65);
- end;
- human.Changed:connect(function(prop)
- if prop=='MoveDirection'then
- if human.MoveDirection.magnitude>.02 then
- Debounces.isMoving=true;
- else
- Debounces.isMoving=false;
- end;
- end;
- end);
- uinps.InputBegan:connect(function(InputObj)
- if InputObj.KeyCode==Enum.KeyCode.Slash then
- local finishEvent=nil;
- Debounces.isTyping=true
- finishEvent=uinps.InputBegan:connect(function(InputObj)
- if InputObj.KeyCode==Enum.KeyCode.Return or InputObj.UserInputType==Enum.UserInputType.MouseButton1 then
- Debounces.isTyping=false;
- finishEvent:disconnect();
- end;
- end);
- end;
- end);
- mouse.KeyDown:connect(function(key)
- if key=='0'then
- Debounces.isSprinting=true;
- playSound(160248522,c.Torso);
- for i=1,3 do
- spawn(function()
- local e=Instance.new('Part',c);
- e.Size=Vector3.new(1,1,1);
- e.Material='Neon';
- e.Color=a();
- e.Anchored=true;
- e.CFrame=c.HumanoidRootPart.CFrame*CFrame.Angles(0,0,-math.pi/2);
- e.CanCollide=false;
- local rm=Instance.new('SpecialMesh',e);
- rm.MeshType='FileMesh';
- rm.MeshId='rbxassetid://3270017';
- rm.Scale=Vector3.new(3.2,3.2,10);
- for x=1,30 do
- wait();
- rm.Scale=rm.Scale:lerp(Vector3.new(i*30,i*30,(4-i)*450),.1);
- e.Transparency=x/30+.5;
- end;
- end);
- end;
- c.HumanoidRootPart.Velocity=c.HumanoidRootPart.CFrame.lookVector*200;
- end;
- end);
- mouse.KeyUp:connect(function(key)
- if key=='0'then
- Debounces.isSprinting=false;
- end;
- end);
- mouse.KeyDown:connect(function(key)
- if key=='v'then
- playSound(201858087,c.Torso,math.random(90,120)/100);
- local oldPos=c.HumanoidRootPart.CFrame.p;
- local mHit=mouse.Hit.p;
- for i=1,2 do
- spawn(function()
- local pos
- if i==1 then pos=oldPos else pos=mHit end
- local p=Instance.new('Part',workspace);
- p.Anchored=true;
- p.CanCollide=false;
- p.Color=a();
- p.FormFactor='Custom';
- p.CFrame=CFrame.new(pos+Vector3.new(0,500,0));
- p.Transparency=.4;
- p.Size=Vector3.new(20,1000,20);
- for i=1,20 do
- wait();
- p.Transparency=.4+(i/10)*.6;
- p.Size=Vector3.new(20-i*1.5,1000,20-i*1.5);
- p.CFrame=CFrame.new(pos+Vector3.new(0,500,0));
- end;
- p:Destroy();
- end);
- end;
- if Debounces.isMoving then
- c.HumanoidRootPart.CFrame=CFrame.new(mouse.Hit.p+Vector3.new(0,4,0),Vector3.new(c.HumanoidRootPart.Velocity.x,mouse.Hit.p.y+4,c.HumanoidRootPart.Velocity.z));
- else
- c.HumanoidRootPart.CFrame=CFrame.new(mouse.Hit.p+Vector3.new(0,4,0),Vector3.new(oldPos.x,mouse.Hit.p.y+4,oldPos.z));
- end;
- end;
- end);
- mouse.KeyDown:connect(function(key)
- if key=='r'then
- local pointTarget=mouse.Hit.p;
- for i=1,20 do
- wait();
- gasterBlast(CFrame.new(pointTarget+Vector3.new(math.sin(tick()*10)*20,5+math.abs(math.sin(tick()*5)*10),math.cos(tick()*10)*20),pointTarget));
- end;
- wait();
- largegasterBlast(CFrame.new(pointTarget+Vector3.new(0,35,0),pointTarget));
- end;
- end);
- mouse.KeyDown:connect(function(key)
- if key=='f'then
- local pointTarget=mouse.Hit.p;
- for i=1,20 do
- wait();
- gasterBlast(CFrame.new(c.HumanoidRootPart.CFrame.p+Vector3.new(0,50,0),pointTarget):toWorldSpace(CFrame.new(math.sin(i/2)*(20-i),math.cos(i/2)*(20-i),-i)));
- end;
- largegasterBlast(CFrame.new(c.HumanoidRootPart.CFrame.p+Vector3.new(0,50,0),pointTarget):toWorldSpace(CFrame.new(0,0,-25)));
- end;
- end);
- mouse.Button1Down:connect(function()
- Debounces.isFlash=true;
- end);
- mouse.Button1Up:connect(function()
- Debounces.isFlash=false;
- end);
- mouse.KeyDown:connect(function(key)
- if key=='k'then
- if music.isPlaying then music:Stop();else music:Play();end;
- end;
- end);
- mouse.KeyDown:connect(function(key)
- if key=='j'then
- if music2.isPlaying then music2:Stop();else music2:Play();end;
- end;
- end);
- mouse.KeyDown:connect(function(key)
- if key=='l'then
- if music3.isPlaying then music3:Stop();else music3:Play();end;
- end;
- end);
- mouse.KeyDown:connect(function(key)
- if key=='p'then
- if music4.isPlaying then music4:Stop();else music4:Play();end;
- end;
- end);
- mouse.KeyDown:connect(function(key)
- if key=='o'then
- if music5.isPlaying then music4:Stop();else music5:Play();end;
- end;
- end);
- mouse.KeyDown:connect(function(key)
- if key=='e'then
- gasterBlast(c.Torso.CFrame.p+Vector3.new(math.sin(tick()*10)*10,12,math.cos(tick()*10)*10),mouse.Hit.p,true);
- end;
- end);
- mouse.KeyDown:connect(function(key)
- if key=='c'then
- largegasterBlast(c.Torso.CFrame.p+Vector3.new(math.sin(tick()*10)*10,12,math.cos(tick()*10)*10),mouse.Hit.p);
- end;
- end);
- mouse.KeyDown:connect(function(key)
- if key=='q'then
- for i=1,5 do
- wait();
- gasterBlast(c.Torso.CFrame.p+Vector3.new(math.sin(tick()*10)*10,12,math.cos(tick()*10)*10),mouse.Hit.p);
- end;
- largegasterBlast(c.Torso.CFrame.p+Vector3.new(0,25,0),mouse.Hit.p);
- end;
- end);
- mouse.KeyDown:connect(function(key)
- if key=='t'then
- local pointTarget=mouse.Hit.p;
- for i=1,20 do
- gasterBlast(pointTarget+Vector3.new(math.sin(math.deg((360/40)*i))*(20-i),5+i,math.cos(math.deg((360/40)*i))*(20-i)),pointTarget);
- end;
- wait(.2);
- for i=1,10 do
- largegasterBlast(pointTarget+Vector3.new(math.sin(math.deg((360/20)*i))*25,20,math.cos(math.deg((360/20)*i))*25),pointTarget);
- end;
- end;
- end);
- human.StateChanged:connect(function(os,ns)
- if c.HumanoidRootPart.Velocity.Y<.1 and Debounces.isJumping==true and ns==Enum.HumanoidStateType.Landed then
- Debounces.isJumping=false;
- end;
- end);
- rs.RenderStepped:connect(function()
- Debounces.FPS=1/rs.RenderStepped:wait();
- if Debounces.FPS<30 then
- Debounces.FPS=30;
- end;
- if Debounces.isSprinting then
- lerpBoom();
- else
- noBoom();
- end;
- for _,v in pairs(rayModel:children())do
- v.Transparency=v.Transparency+.06/(Debounces.FPS/60);
- if v.Transparency>.99 then v:Destroy();return;end;
- v.CanCollide=true;
- local tParts=v:GetTouchingParts();
- v.CanCollide=false;
- local vCFrame=v.CFrame;
- v.Size=v.Size+Vector3.new(0,1,1)/(Debounces.FPS/60);
- v.CFrame=vCFrame;
- for _,x in pairs(tParts)do
- if x and x.Parent and x.Parent:FindFirstChild'Humanoid'and x.Parent.Humanoid:isA'Humanoid'and x.Parent~=c then
- x.Parent.Humanoid:TakeDamage(1000000,2000000);
- end;
- end;
- end;
- local FPSLerp=AnimStat.lerpSpeed/(Debounces.FPS/60);
- end);
- local verlet = {}
- verlet.step_time = 1 / 50
- verlet.gravity = Vector3.new(0, -10, 0)
- local char = game.Players.LocalPlayer.Character
- local torso = char:WaitForChild("Torso")
- local parts = {}
- local render = game:GetService("RunService").RenderStepped
- wait(2)
- local point = {}
- local link = {}
- local rope = {}
- local function ccw(A,B,C)
- return (C.y-A.y) * (B.x-A.x) > (B.y-A.y) * (C.x-A.x)
- end
- local function intersect(A,B,C,D)
- return ccw(A,C,D) ~= ccw(B,C,D) and ccw(A,B,C) ~= ccw(A,B,D)
- end
- local function vec2(v)
- return Vector2.new(v.x, v.z)
- end
- function point:step()
- if not self.fixed then
- local derivative = (self.position - self.last_position) * 0.95
- self.last_position = self.position
- self.position = self.position + derivative + (self.velocity * verlet.step_time ^ 2)
- --[[local torsoP = torso.CFrame * CFrame.new(-1, 0, 0.5)
- local torsoE = torso.CFrame * CFrame.new(1, 0, 0.5)
- local pointE = self.position + torso.CFrame.lookVector * 100
- local doIntersect = intersect(vec2(torsoP.p), vec2(torsoE.p), vec2(self.position), vec2(pointE))
- if not doIntersect then
- self.postition = self.position - torso.CFrame.lookVector * 10
- end]]
- end
- end
- function link:step()
- for i = 1, 1 do
- local distance = self.point1.position - self.point2.position
- local magnitude = distance.magnitude
- local differance = (self.length - magnitude) / magnitude
- local translation = ((self.point1.fixed or self.point2.fixed) and 1 or 0.6) * distance * differance
- if not self.point1.fixed then
- self.point1.position = self.point1.position + translation
- end
- if not self.point2.fixed then
- self.point2.position = self.point2.position - translation
- end
- end
- end
- function verlet.new(class, a, b, c)
- if class == "Point" then
- local new = {}
- setmetatable(new, {__index = point})
- new.class = class
- new.position = a or Vector3.new()
- new.last_position = new.position
- new.velocity = verlet.gravity
- new.fixed = false
- return new
- elseif class == "Link" then
- local new = {}
- setmetatable(new, {__index = link})
- new.class = class
- new.point1 = a
- new.point2 = b
- new.length = c or (a.position - b.position).magnitude
- return new
- elseif class == "Rope" then
- local new = {}
- setmetatable(new, {__index = link})
- new.class = class
- new.start_point = a
- new.finish_point = b
- new.points = {}
- new.links = {}
- local inc = (b - a) / 10
- for i = 0, 10 do
- table.insert(new.points, verlet.new("Point", a + (i * inc)))
- end
- for i = 2, #new.points do
- table.insert(new.links, verlet.new("Link", new.points[i - 1], new.points[i]))
- end
- return new
- end
- end
- local tris = {}
- local triParts = {}
- local function GetDiscoColor(hue)
- local section = hue % 1 * 3
- local secondary = 0.5 * math.pi * (section % 1)
- if section < 1 then
- return Color3.new(0, 0, 0)
- elseif section < 2 then
- return Color3.new(0, 0, 0)
- else
- return Color3.new(0, 0, 0)
- end
- end
- local function setupPart(part)
- part.Anchored = true
- part.FormFactor = 3
- part.CanCollide = false
- part.TopSurface = 10
- part.BottomSurface = 10
- part.LeftSurface = 10
- part.RightSurface = 10
- part.FrontSurface = 10
- part.BackSurface = 10
- part.Material = "Neon"
- local m = Instance.new("SpecialMesh", part)
- m.MeshType = "Wedge"
- m.Scale = Vector3.new(0.2, 1, 1)
- return part
- end
- local function CFrameFromTopBack(at, top, back)
- local right = top:Cross(back)
- 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)
- end
- local function drawTri(parent, a, b, c)
- local this = {}
- local mPart1 = table.remove(triParts, 1) or setupPart(Instance.new("Part"))
- local mPart2 = table.remove(triParts, 1) or setupPart(Instance.new("Part"))
- function this:Set(a, b, c)
- local ab, bc, ca = b-a, c-b, a-c
- local abm, bcm, cam = ab.magnitude, bc.magnitude, ca.magnitude
- local edg1 = math.abs(0.5 + ca:Dot(ab)/(abm*abm))
- local edg2 = math.abs(0.5 + ab:Dot(bc)/(bcm*bcm))
- local edg3 = math.abs(0.5 + bc:Dot(ca)/(cam*cam))
- if edg1 < edg2 then
- if edg1 >= edg3 then
- a, b, c = c, a, b
- ab, bc, ca = ca, ab, bc
- abm = cam
- end
- else
- if edg2 < edg3 then
- a, b, c = b, c, a
- ab, bc, ca = bc, ca, ab
- abm = bcm
- else
- a, b, c = c, a, b
- ab, bc, ca = ca, ab, bc
- abm = cam
- end
- end
- local len1 = -ca:Dot(ab)/abm
- local len2 = abm - len1
- local width = (ca + ab.unit*len1).magnitude
- local maincf = CFrameFromTopBack(a, ab:Cross(bc).unit, -ab.unit)
- if len1 > 0.2 then
- mPart1.Parent = parent
- mPart1.Size = Vector3.new(0.2, width, len1)
- mPart1.CFrame = maincf*CFrame.Angles(math.pi,0,math.pi/2)*CFrame.new(0,width/2,len1/2)
- else
- mPart1.Parent = nil
- end
- if len2 > 0.2 then
- mPart2.Parent = parent
- mPart2.Size = Vector3.new(0.2, width, len2)
- mPart2.CFrame = maincf*CFrame.Angles(math.pi,math.pi,-math.pi/2)*CFrame.new(0,width/2,-len1 - len2/2)
- else
- mPart2.Parent = nil
- end
- end
- function this:SetProperty(prop, value)
- mPart1[prop] = value
- mPart2[prop] = value
- end
- this:Set(a, b, c)
- function this:Destroy()
- mPart1:Destroy()
- mPart2:Destroy()
- end
- this.p1 = mPart1
- this.p2 = mPart2
- this.p1.BrickColor = BrickColor.new(GetDiscoColor(math.noise(0.5, 0.5, this.p1.CFrame.Y * 0.5 + time())))
- this.p2.BrickColor = BrickColor.new(GetDiscoColor(math.noise(0.5, 0.5, this.p2.CFrame.Y * 0.5 + time())))
- return this
- end
- function verlet.draw(object, id)
- if object.class == "Point" then
- local part = parts[id]
- part.BrickColor = BrickColor.new(107, 0, 107)
- part.Transparency = 0
- part.formFactor = 3
- part.Anchored = true
- part.CanCollide = false
- part.TopSurface = 0
- part.BottomSurface = 0
- part.Size = Vector3.new(0.35, 0.35, 0.35)
- part.Material = "Neon"
- part.CFrame = CFrame.new(object.position)
- part.Parent = torso
- return part
- elseif object.class == "Link" then
- local part = parts[id]
- local dist = (object.point1.position - object.point2.position).magnitude
- part.Size = Vector3.new(0.2, 0.2, dist)
- part.CFrame = CFrame.new(object.point1.position, object.point2.position) * CFrame.new(0, 0, dist * -0.5)
- part.Parent = torso
- return part
- end
- end
- function verlet.clear()
- for _, v in pairs(workspace:GetChildren()) do
- if v.Name == "Part" then
- v:Destroy()
- end
- end
- end
- local points = {}
- local links = {}
- for x = 0, 2 do
- points[x] = {}
- for y = 0, 3 do
- points[x][y] = verlet.new("Point", torso.Position + Vector3.new(x * 0.8 - 2, 2 - y * 0.8, 5 + y * 0.4))
- points[x][y].fixed = y == 0
- end
- end
- for x = 1, 2 do
- for y = 0, 3 do
- links[#links + 1] = verlet.new("Link", points[x][y], points[x - 1][y], 1 + y * 0.08)
- end
- end
- for x = 0, 2 do
- for y = 1, 3 do
- links[#links + 1] = verlet.new("Link", points[x][y], points[x][y - 1], 1.2 + y * 0.03)
- end
- end
- render:connect(function()
- for x = 0, 2 do
- for y = 0, 3 do
- if y == 0 then
- points[x][y].position = (torso.CFrame * CFrame.new(x * 1 - 1, 1, 0.5)).p
- else
- points[x][y]:step()
- end
- end
- end
- for i = 1, #links do
- links[i]:step()
- end
- for i = 1, #tris do
- triParts[#triParts + 1] = tris[i].p1
- triParts[#triParts + 1] = tris[i].p2
- end
- tris = {}
- for x = 1, 2 do
- for y = 1, 3 do
- tris[#tris + 1] = drawTri(torso, points[x - 1][y - 1].position, points[x - 1][y].position, points[x][y - 1].position)
- tris[#tris + 1] = drawTri(torso, points[x][y].position, points[x - 1][y].position, points[x][y - 1].position)
- end
- end
- end)
Add Comment
Please, Sign In to add comment