Tool=script.Parent Handle=Tool:WaitForChild("\072\097\110\100\108\101")Players=game:GetService("\080\108\097\121\101\114\115")Debris=game:GetService("\068\101\098\114\105\115")RemovalMonitor=script:WaitForChild("\082\101\109\111\118\097\108\077\111\110\105\116\111\114")CarpetPieces={{MeshId=223079795,Angle=160};{MeshId=223079835;Angle=100},{MeshId=223079888;Angle=100};{MeshId=223079981,Angle=160}}CarpetSize=Vector3.new(3,.5,6.5)BaseUrl="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061"Rate=.1 BasePart=Instance.new("\080\097\114\116")BasePart.Material=Enum.Material.Plastic BasePart.Shape=Enum.PartType.Block BasePart.TopSurface=Enum.SurfaceType.Smooth BasePart.BottomSurface=Enum.SurfaceType.Smooth BasePart.FormFactor=Enum.FormFactor.Custom BasePart.Size=Vector3.new(.2,.2,.2)BasePart.CanCollide=true BasePart.Locked=true ColorPart=BasePart:Clone()ColorPart.Name="\067\111\108\111\114\080\097\114\116"ColorPart.Reflectance=.25 ColorPart.Transparency=.1 ColorPart.Material=Enum.Material.SmoothPlastic ColorPart.FrontSurface=Enum.SurfaceType.SmoothNoOutlines ColorPart.BackSurface=Enum.SurfaceType.SmoothNoOutlines ColorPart.TopSurface=Enum.SurfaceType.SmoothNoOutlines ColorPart.BottomSurface=Enum.SurfaceType.SmoothNoOutlines ColorPart.LeftSurface=Enum.SurfaceType.SmoothNoOutlines ColorPart.RightSurface=Enum.SurfaceType.SmoothNoOutlines ColorPart.Size=Vector3.new(1,1,1)ColorPart.Anchored=true ColorPart.CanCollide=false ColorMesh=Instance.new("\083\112\101\099\105\097\108\077\101\115\104")ColorMesh.Name="\077\101\115\104"ColorMesh.MeshType=Enum.MeshType.FileMesh ColorMesh.MeshId=BaseUrl.."\057\056\053\054\056\057\056"ColorMesh.TextureId=BaseUrl.."\049\051\054\049\048\057\055"ColorMesh.Scale=ColorPart.Size*2 ColorMesh.Offset=Vector3.new(0,0,0)ColorMesh.VertexColor=Vector3.new(1,1,1)ColorMesh.Parent=ColorPart ColorLight=Instance.new("\080\111\105\110\116\076\105\103\104\116")ColorLight.Name="\076\105\103\104\116"ColorLight.Brightness=50 ColorLight.Range=8 ColorLight.Shadows=false ColorLight.Enabled=true ColorLight.Parent=ColorPart RainbowColors={Vector3.new(1,0,0);Vector3.new(1,.5,0);Vector3.new(1,1,0);Vector3.new(0,1,0),Vector3.new(0,1,1);Vector3.new(0,0,1);Vector3.new(.5,0,1)}Animations={Sit={Animation=Tool:WaitForChild("\083\105\116"),FadeTime=nil;Weight=nil,Speed=nil,Duration=nil}}Grips={Normal=CFrame.new(-1.5,0,0,0,0,-1,-1,8.90154915e-05,0,8.90154915e-05,1,0);Flying=CFrame.new(-1.5,.5,-0.75,-1,0,-8.99756625e-09,-8.99756625e-09,8.10000031e-08,1,7.28802977e-16,.99999994,-8.10000103e-08)}Flying=false ToolEquipped=false ServerControl=Tool:FindFirstChild("\083\101\114\118\101\114\067\111\110\116\114\111\108")or Instance.new("\082\101\109\111\116\101\070\117\110\099\116\105\111\110")ServerControl.Name="\083\101\114\118\101\114\067\111\110\116\114\111\108"ServerControl.Parent=Tool ClientControl=Tool:FindFirstChild("\067\108\105\101\110\116\067\111\110\116\114\111\108")or Instance.new("\082\101\109\111\116\101\070\117\110\099\116\105\111\110")ClientControl.Name="\067\108\105\101\110\116\067\111\110\116\114\111\108"ClientControl.Parent=Tool Handle.Transparency=0 Tool.Grip=Grips.Normal Tool.Enabled=true function Clamp(h,F,m)return math.max(math.min(m,h),F)end function TransformModel(h,F,m,T)local l=type(h)~="\116\097\098\108\101"and{h}or h for h,l in pairs(l)do if l:IsA("\066\097\115\101\080\097\114\116")then l.CFrame=m:toWorldSpace(F:toObjectSpace(l.CFrame))end if T then TransformModel(l:GetChildren(),F,m,true)end end end function Weld(h,F)local m={}local T={}local function l(h,F)for h,N in pairs(h:GetChildren())do if N:IsA("\066\097\115\101\080\097\114\116")then if N~=F then local h=Instance.new("\087\101\108\100")h.Name="\087\101\108\100"h.Part0=F h.Part1=N h.C0=F.CFrame:inverse()h.C1=N.CFrame:inverse()h.Parent=F table.insert(T,h)end table.insert(m,N)end l(N,F)end end l(h,F)return m,T end function CleanUp()for h,F in pairs(Tool:GetChildren())do if F:IsA("\066\097\115\101\080\097\114\116")and F~=Handle then F:Destroy()end end end function CreateRainbow(h)local F=Instance.new("\077\111\100\101\108")F.Name="\082\097\105\110\098\111\119\080\097\114\116"for m,T in pairs(RainbowColors)do local l=ColorPart:Clone()l.Name="\080\097\114\116"l.Size=Vector3.new(.5,.5,h)l.CFrame=l.CFrame*CFrame.new(l.Size.X*(m-1),0,0)l.Mesh.Scale=l.Size*2 l.Mesh.VertexColor=T l.Light.Color=Color3.new(T.X,T.Y,T.Z)l.Parent=F end local m=BasePart:Clone()m.Name="\066\111\117\110\100\105\110\103\066\111\120"m.Transparency=1 m.Size=F:GetModelSize()m.Anchored=true m.CanCollide=false m.CFrame=F:GetModelCFrame()m.Parent=F return F end function GetRainbowModel()local h=Player.Name.."\'\115 \082\097\105\110\098\111\119"local F=(game:GetService("\087\111\114\107\115\112\097\099\101")):FindFirstChild(h)if not F then F=Instance.new("\077\111\100\101\108")F.Name=h local m=RemovalMonitor:Clone()m.Disabled=false m.Parent=F end return F end function CheckIfAlive()return(Character and(Character.Parent and(Humanoid and(Humanoid.Parent and(Humanoid.Health>0 and(Torso and(Torso.Parent and(Player and Player.Parent))))))))and true or false end function Activated()if not Tool.Enabled then return end Tool.Enabled=false Flying=not Flying if Flying then Handle.Transparency=1 CleanUp()local h={}for F,m in pairs(CarpetPieces)do local T=BasePart:Clone()T.Size=Vector3.new(CarpetSize.X,CarpetSize.Y,CarpetSize.Z/#CarpetPieces)local l=Instance.new("\083\112\101\099\105\097\108\077\101\115\104")l.MeshType=Enum.MeshType.FileMesh l.MeshId=BaseUrl..m.MeshId l.TextureId=BaseUrl.."\050\050\051\048\056\048\048\051\056"l.Scale=Vector3.new(1.125,1.125,1.125)l.VertexColor=Vector3.new(1,1,1)l.Offset=Vector3.new(0,0,0)l.Parent=T local N=Instance.new("\087\101\108\100")N.Part0=Handle N.Part1=T local a=(F==1 or F==#CarpetPieces)and-0.005 or 0 local Q=(-(Handle.Size.Z/2-T.Size.Z/2)+T.Size.Z*(F-1))+(F==2 and.245 or F==3 and.04 or F==#CarpetPieces and.28 or 0)N.C1=CFrame.new(0,a,Q)N.Parent=T table.insert(h,{Part=T,Weld=N;InitialCFrame=N.C0;Angle=m.Angle})T.Parent=Tool end Spawn(function()InvokeClient("\080\108\097\121\065\110\105\109\097\116\105\111\110",Animations.Sit)Tool.Grip=Grips.Flying end)FlightSpin=Instance.new("\066\111\100\121\071\121\114\111")FlightSpin.Name="\070\108\105\103\104\116\083\112\105\110"FlightSpin.P=1000000 FlightSpin.maxTorque=Vector3.new(FlightSpin.P,FlightSpin.P,FlightSpin.P)FlightSpin.cframe=Torso.CFrame FlightPower=Instance.new("\066\111\100\121\086\101\108\111\099\105\116\121")FlightPower.Name="\070\108\105\103\104\116\080\111\119\101\114"FlightPower.velocity=Vector3.new(0,0,0)FlightPower.P=1000000 FlightPower.maxForce=Vector3.new(FlightPower.P,FlightPower.P,FlightPower.P)FlightPower.P=10000 FlightHold=Instance.new("\066\111\100\121\080\111\115\105\116\105\111\110")FlightHold.Name="\070\108\105\103\104\116\072\111\108\100"FlightHold.P=100000 FlightHold.maxForce=Vector3.new(0,0,0)FlightHold.position=Torso.Position FlightSpin.Parent=Torso FlightPower.Parent=Torso FlightHold.Parent=Torso Spawn(function()local h=nil while Flying and(ToolEquipped and CheckIfAlive())do local F=Handle.Position local m=Torso.Velocity m=(Vector3.new(m.X,0,m.Z)).magnitude if h and m>10 then Spawn(function()local m=GetRainbowModel()local T=(h-F).magnitude local l=T+3.5 local N=CreateRainbow(l)local a=CFrame.new(h+(F-h).unit*(T/2),F)TransformModel(N,N:GetModelCFrame(),a,true)Debris:AddItem(N,1)N.Parent=m if m and not m.Parent then m.Parent=game:GetService("\087\111\114\107\115\112\097\099\101")end h=F end)elseif not h then h=F end wait(Rate)end end)elseif not Flying then Torso.Velocity=Vector3.new(0,0,0)Torso.RotVelocity=Vector3.new(0,0,0)for h,F in pairs({FlightSpin;FlightPower,FlightHold})do if F and F.Parent then F:Destroy()end end Spawn(function()Tool.Grip=Grips.Normal InvokeClient("\083\116\111\112\065\110\105\109\097\116\105\111\110",Animations.Sit)end)end wait(2)Tool.Enabled=true end function Equipped(h)Character=Tool.Parent Humanoid=Character:FindFirstChild("\072\117\109\097\110\111\105\100")Torso=Character:FindFirstChild("\084\111\114\115\111")Player=Players:GetPlayerFromCharacter(Character)if not CheckIfAlive()then return end Tool.Grip=Grips.Normal ToolEquipped=true end function Unequipped()Flying=false for h,F in pairs({FlightSpin;FlightPower,FlightHold})do if F and F.Parent then F:Destroy()end end CleanUp()Handle.Transparency=0 ToolEquipped=false end function OnServerInvoke(h,F,m)if h~=Player or not ToolEquipped or not m or not CheckIfAlive()then return end end function InvokeClient(h,F)local m=nil pcall(function()m=ClientControl:InvokeClient(Player,h,F)end)return m end CleanUp()ServerControl.OnServerInvoke=OnServerInvoke Tool.Activated:connect(Activated)Tool.Equipped:connect(Equipped)Tool.Unequipped:connect(Unequipped)


Tool = script.Parent
Handle = Tool:WaitForChild("Handle")

Players = game:GetService("Players")
Debris = game:GetService("Debris")

RemovalMonitor = script:WaitForChild("RemovalMonitor")

CarpetPieces = {
	{MeshId = 223079795, Angle = 160},
	{MeshId = 223079835, Angle = 100},
	{MeshId = 223079888, Angle = 100},
	{MeshId = 223079981, Angle = 160},
}

CarpetSize = Vector3.new(3, 0.5, 6.5)

BaseUrl = "http://www.roblox.com/asset/?id="

Rate = (1 / 10)

BasePart = Instance.new("Part")
BasePart.Material = Enum.Material.Plastic
BasePart.Shape = Enum.PartType.Block
BasePart.TopSurface = Enum.SurfaceType.Smooth
BasePart.BottomSurface = Enum.SurfaceType.Smooth
BasePart.FormFactor = Enum.FormFactor.Custom
BasePart.Size = Vector3.new(0.2, 0.2, 0.2)
BasePart.CanCollide = true
BasePart.Locked = true

ColorPart = BasePart:Clone()
ColorPart.Name = "ColorPart"
ColorPart.Reflectance = 0.25
ColorPart.Transparency = 0.1
ColorPart.Material = Enum.Material.SmoothPlastic
ColorPart.FrontSurface = Enum.SurfaceType.SmoothNoOutlines
ColorPart.BackSurface = Enum.SurfaceType.SmoothNoOutlines
ColorPart.TopSurface = Enum.SurfaceType.SmoothNoOutlines
ColorPart.BottomSurface = Enum.SurfaceType.SmoothNoOutlines
ColorPart.LeftSurface = Enum.SurfaceType.SmoothNoOutlines
ColorPart.RightSurface = Enum.SurfaceType.SmoothNoOutlines
ColorPart.Size = Vector3.new(1, 1, 1)
ColorPart.Anchored = true
ColorPart.CanCollide = false
ColorMesh = Instance.new("SpecialMesh")
ColorMesh.Name = "Mesh"
ColorMesh.MeshType = Enum.MeshType.FileMesh
ColorMesh.MeshId = (BaseUrl .. "9856898")
ColorMesh.TextureId = (BaseUrl .. "1361097")
ColorMesh.Scale = (ColorPart.Size * 2) --Default mesh scale is 1/2 the size of a 1x1x1 brick.
ColorMesh.Offset = Vector3.new(0, 0, 0)
ColorMesh.VertexColor = Vector3.new(1, 1, 1)
ColorMesh.Parent = ColorPart
ColorLight = Instance.new("PointLight")
ColorLight.Name = "Light"
ColorLight.Brightness = 50
ColorLight.Range = 8
ColorLight.Shadows = false
ColorLight.Enabled = true
ColorLight.Parent = ColorPart

RainbowColors = {
	Vector3.new(1, 0, 0),
	Vector3.new(1, 0.5, 0),
	Vector3.new(1, 1, 0),
	Vector3.new(0, 1, 0),
	Vector3.new(0, 1, 1),
	Vector3.new(0, 0, 1),
	Vector3.new(0.5, 0, 1)
}

Animations = {
	Sit = {Animation = Tool:WaitForChild("Sit"), FadeTime = nil, Weight = nil, Speed = nil, Duration = nil},
}

Grips = {
	Normal = CFrame.new(-1.5, 0, 0, 0, 0, -1, -1, 8.90154915e-005, 0, 8.90154915e-005, 1, 0),
	Flying = CFrame.new(-1.5, 0.5, -0.75, -1, 0, -8.99756625e-009, -8.99756625e-009, 8.10000031e-008, 1, 7.28802977e-016, 0.99999994, -8.10000103e-008)
}

Flying = false
ToolEquipped = false

ServerControl = (Tool:FindFirstChild("ServerControl") or Instance.new("RemoteFunction"))
ServerControl.Name = "ServerControl"
ServerControl.Parent = Tool

ClientControl = (Tool:FindFirstChild("ClientControl") or Instance.new("RemoteFunction"))
ClientControl.Name = "ClientControl"
ClientControl.Parent = Tool

Handle.Transparency = 0
Tool.Grip = Grips.Normal
Tool.Enabled = true

function Clamp(Number, Min, Max)
	return math.max(math.min(Max, Number), Min)
end

function TransformModel(Objects, Center, NewCFrame, Recurse)
	local Objects = ((type(Objects) ~= "table" and {Objects}) or Objects)
	for i, v in pairs(Objects) do
		if v:IsA("BasePart") then
			v.CFrame = NewCFrame:toWorldSpace(Center:toObjectSpace(v.CFrame))
		end
		if Recurse then
			TransformModel(v:GetChildren(), Center, NewCFrame, true)
		end
	end
end

function Weld(Parent, PrimaryPart)
	local Parts = {}
	local Welds = {}
	local function WeldModel(Parent, PrimaryPart)
		for i, v in pairs(Parent:GetChildren()) do
			if v:IsA("BasePart") then
				if v ~= PrimaryPart then
					local Weld = Instance.new("Weld")
					Weld.Name = "Weld"
					Weld.Part0 = PrimaryPart
					Weld.Part1 = v
					Weld.C0 = PrimaryPart.CFrame:inverse()
					Weld.C1 = v.CFrame:inverse()
					Weld.Parent = PrimaryPart
					table.insert(Welds, Weld)
				end
				table.insert(Parts, v)
			end
			WeldModel(v, PrimaryPart)
		end
	end
	WeldModel(Parent, PrimaryPart)
	return Parts, Welds
end

function CleanUp()
	for i, v in pairs(Tool:GetChildren()) do
		if v:IsA("BasePart") and v ~= Handle then
			v:Destroy()
		end
	end
end

function CreateRainbow(Length)
	local RainbowModel = Instance.new("Model")
	RainbowModel.Name = "RainbowPart"
	for i, v in pairs(RainbowColors) do
		local Part = ColorPart:Clone()
		Part.Name = "Part"
		Part.Size = Vector3.new(0.5, 0.5, Length)
		Part.CFrame = Part.CFrame * CFrame.new((Part.Size.X * (i - 1)), 0, 0)
		Part.Mesh.Scale = (Part.Size * 2)
		Part.Mesh.VertexColor = v
		Part.Light.Color = Color3.new(v.X, v.Y, v.Z)
		Part.Parent = RainbowModel
	end
	local RainbowBoundingBox = BasePart:Clone()
	RainbowBoundingBox.Name = "BoundingBox"
	RainbowBoundingBox.Transparency = 1
	RainbowBoundingBox.Size = RainbowModel:GetModelSize()
	RainbowBoundingBox.Anchored = true
	RainbowBoundingBox.CanCollide = false
	RainbowBoundingBox.CFrame = RainbowModel:GetModelCFrame()
	RainbowBoundingBox.Parent = RainbowModel
	return RainbowModel
end

function GetRainbowModel()
	local ModelName = (Player.Name .. "'s Rainbow")
	local Model = game:GetService("Workspace"):FindFirstChild(ModelName)
	if not Model then
		Model = Instance.new("Model")
		Model.Name = ModelName
		local RemovalMonitorClone = RemovalMonitor:Clone()
		RemovalMonitorClone.Disabled = false
		RemovalMonitorClone.Parent = Model
	end
	return Model
end

function CheckIfAlive()
	return (((Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0 and Torso and Torso.Parent and Player and Player.Parent) and true) or false)
end

function Activated()
	if not Tool.Enabled then
		return
	end
	Tool.Enabled = false
	Flying = not Flying
	if Flying then
		Handle.Transparency = 1
		CleanUp()
		local CarpetParts = {}
		for i, v in pairs(CarpetPieces) do
			local CarpetPart = BasePart:Clone()
			CarpetPart.Size = Vector3.new(CarpetSize.X, CarpetSize.Y, (CarpetSize.Z / #CarpetPieces))
			local Mesh = Instance.new("SpecialMesh")
			Mesh.MeshType = Enum.MeshType.FileMesh
			Mesh.MeshId = (BaseUrl .. v.MeshId)
			Mesh.TextureId = (BaseUrl .. "223080038")
			Mesh.Scale = Vector3.new(1.125, 1.125, 1.125)
			Mesh.VertexColor = Vector3.new(1, 1, 1)
			Mesh.Offset = Vector3.new(0, 0, 0)
			Mesh.Parent = CarpetPart
			local Weld = Instance.new("Weld")
			Weld.Part0 = Handle
			Weld.Part1 = CarpetPart
			local XOffset = (((i == 1 or i == #CarpetPieces) and -0.005) or 0)
			local YOffset = ((-((Handle.Size.Z / 2) - (CarpetPart.Size.Z / 2))) + ((CarpetPart.Size.Z * (i - 1))) + ((i == 2 and 0.245) or (i == 3 and 0.04) or (i == #CarpetPieces and 0.28) or 0))
			Weld.C1 = CFrame.new(0, XOffset, YOffset)
			Weld.Parent = CarpetPart
			table.insert(CarpetParts, {Part = CarpetPart, Weld = Weld, InitialCFrame = Weld.C0, Angle = v.Angle})
			CarpetPart.Parent = Tool
		end	
		
		Spawn(function()
			InvokeClient("PlayAnimation", Animations.Sit)
			Tool.Grip = Grips.Flying
		end)
		
		FlightSpin = Instance.new("BodyGyro")
		FlightSpin.Name = "FlightSpin"
		FlightSpin.P = 1000000
		FlightSpin.maxTorque = Vector3.new(FlightSpin.P, FlightSpin.P, FlightSpin.P)
		FlightSpin.cframe = Torso.CFrame
		
		FlightPower = Instance.new("BodyVelocity")
		FlightPower.Name = "FlightPower"
		FlightPower.velocity = Vector3.new(0, 0, 0)
		FlightPower.P = 1000000
		FlightPower.maxForce = Vector3.new(FlightPower.P, FlightPower.P, FlightPower.P)
		FlightPower.P = 10000
		
		FlightHold = Instance.new("BodyPosition")
		FlightHold.Name = "FlightHold"
		FlightHold.P = 100000
		FlightHold.maxForce = Vector3.new(0, 0, 0)
		FlightHold.position = Torso.Position
		
		FlightSpin.Parent = Torso
		FlightPower.Parent = Torso
		FlightHold.Parent = Torso
		
		Spawn(function()
			local LastPlace = nil
			while Flying and ToolEquipped and CheckIfAlive() do
				
				local CurrentPlace = Handle.Position
				local Velocity = Torso.Velocity
				Velocity = Vector3.new(Velocity.X, 0, Velocity.Z).magnitude
				
				if LastPlace and Velocity > 10 then
					
					Spawn(function()
						local Model = GetRainbowModel()
						local Distance = (LastPlace - CurrentPlace).magnitude
						local Length = Distance + 3.5
						
						local RainbowModel = CreateRainbow(Length)
						
						--Thanks so much to ArceusInator for helping solve this part!
						local RainbowCFrame = CFrame.new((LastPlace + (CurrentPlace - LastPlace).unit * (Distance / 2)), CurrentPlace)
						
						TransformModel(RainbowModel, RainbowModel:GetModelCFrame(), RainbowCFrame, true)
						Debris:AddItem(RainbowModel, 1)
						RainbowModel.Parent = Model
						
						if Model and not Model.Parent then
							Model.Parent = game:GetService("Workspace")
						end
						
						LastPlace = CurrentPlace
					end)
				elseif not LastPlace then
					LastPlace = CurrentPlace
				end
				
				wait(Rate)
			end
		end)
	elseif not Flying then
		Torso.Velocity = Vector3.new(0, 0, 0)
		Torso.RotVelocity = Vector3.new(0, 0, 0)
		
		for i, v in pairs({FlightSpin, FlightPower, FlightHold}) do
			if v and v.Parent then
				v:Destroy()
			end
		end
		Spawn(function()
			Tool.Grip = Grips.Normal
			InvokeClient("StopAnimation", Animations.Sit)
		end)
	end
	
	wait(2)
	
	Tool.Enabled = true
end

function Equipped(Mouse)
	Character = Tool.Parent
	Humanoid = Character:FindFirstChild("Humanoid")
	Torso = Character:FindFirstChild("Torso")
	Player = Players:GetPlayerFromCharacter(Character)
	if not CheckIfAlive() then
		return
	end
	Tool.Grip = Grips.Normal
	ToolEquipped = true
end

function Unequipped()
	Flying = false
	for i, v in pairs({FlightSpin, FlightPower, FlightHold}) do
		if v and v.Parent then
			v:Destroy()
		end
	end
	CleanUp()
	Handle.Transparency = 0
	ToolEquipped = false
end

function OnServerInvoke(player, mode, value)
	if player ~= Player or not ToolEquipped or not value or not CheckIfAlive() then
		return
	end
end

function InvokeClient(Mode, Value)
	local ClientReturn = nil
	pcall(function()
		ClientReturn = ClientControl:InvokeClient(Player, Mode, Value)
	end)
	return ClientReturn
end

CleanUp()

ServerControl.OnServerInvoke = OnServerInvoke

Tool.Activated:connect(Activated)
Tool.Equipped:connect(Equipped)
Tool.Unequipped:connect(Unequipped)
