Advertisement
Hellotop2

Untitled

Jan 13th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. WheelSize=3.8;motorSpeed=0.05;car=script.Parent.Parent;Base=car:FindFirstChild("Base")Left=car:FindFirstChild("Left")Right=car:FindFirstChild("Right")function MakeDoor(a,b,c,d)local e=Instance.new("Motor",car)e.Name=a.Name.."Motor"e.Part0=b;e.Part1=a;e.C0=d;e.C1=c;e.MaxVelocity=0.05;b.CanCollide=true;local f=false;b.Touched:connect(function(g)if not f and g.Parent and g.Name=="HumanoidRootPart"and game:GetService("Players"):GetPlayerFromCharacter(g.Parent)then f=true;b.CanCollide=false;e.DesiredAngle=math.pi/3;wait(1.5)e.DesiredAngle=0;wait(0.5)b.CanCollide=true;f=false end end)end;function MakeWeldDoor(a,b)local e=Instance.new("Motor6D",car)e.Name=a.Name.."Motor"e.Part0=b;e.Part1=a;e.C1=a.CFrame:inverse()*b.CFrame;b.CanCollide=false end;function GetCFrame(h)if h:IsA("CFrameValue")then return h.Value elseif h:IsA("StringValue")then local i=nil;pcall(function()i=CFrame.new(h.Value:match("(.+),(.+),(.+),(.+),(.+),(.+),(.+),(.+),(.+),(.+),(.+),(.+)"))end)return i end end;for j,k in pairs(car:GetChildren())do if k:IsA("Motor6D")then k:Destroy()end end;for j,l in pairs(car:GetChildren())do if l:IsA("BasePart")and l.Name:find("DoorHinge")then local m=l.Name:match("DoorHinge(.*)")local n=car:FindFirstChild("Door"..m)if n then local o=n:FindFirstChild("DoorCFrame")local p=n:FindFirstChild("HingeCFrame")if o and p then local q=GetCFrame(o)local r=GetCFrame(p)if q and r then MakeDoor(l,n,r,q)else MakeWeldDoor(l,n)end else MakeWeldDoor(l,n)end end end end;if Base then if Left then leftMotor=Instance.new("Motor6D",car)leftMotor.Name="LeftMotor"leftMotor.Part0=Left;leftMotor.Part1=Base;leftMotor.C0=CFrame.new(-WheelSize/2-Left.Size.x/2,0,0)*CFrame.Angles(math.pi/2,0,-math.pi/2)leftMotor.C1=CFrame.new(Base.Size.x/2+Left.Size.x+WheelSize/2,0,0)*CFrame.Angles(math.pi/2,0,math.pi/2)leftMotor.MaxVelocity=motorSpeed end;if Right then rightMotor=Instance.new("Motor6D",car)rightMotor.Name="RightMotor"rightMotor.Part0=Right;rightMotor.Part1=Base;rightMotor.C0=CFrame.new(-WheelSize/2-Right.Size.x/2,0,0)*CFrame.Angles(math.pi/2,0,math.pi/2)rightMotor.C1=CFrame.new(-Base.Size.x/2-Right.Size.x-WheelSize/2,0,0)*CFrame.Angles(math.pi/2,0,math.pi/2)rightMotor.MaxVelocity=motorSpeed end end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement