local m=581150091 local U=require(m)local function q(m,U)U(m)for m,n in next,m:GetChildren()do q(n,U)end end Functions.PlaySound=function(m,U,q)if m and m.Parent.Name=="\083\101\097\116"then m.Pitch=U m.Volume=q m:Play()end end Functions.StopSound=function(m,U)if m and m.Parent.Name=="\083\101\097\116"then m.Volume=U m:Stop()end end Functions.AnchorPart=function(m,U)if m and(m:IsA("\066\097\115\101\080\097\114\116")and m.Name=="\083\101\097\116")then m.Anchored=U end end Functions.UndoTags=function(m,U,q)U.Value=nil q.Value=nil m.Value=nil end Functions.UndoHasWelded=function(m)if m.Value and m.Value.Parent then m.Value.Parent.HasWelded.Value=false m.Value=nil end end Functions.TiltMotor=function(m,U)if m and m.Name=="\084\105\108\116\077\111\116\111\114"then m.DesiredAngle=U end end Functions.DeleteWelds=function(m)if m and(m:IsA("\066\097\115\101\080\097\114\116")and m.Name=="\083\101\097\116")then for m,U in pairs(m:GetChildren())do if U:IsA("\077\111\116\111\114\054\068")then U:Destroy()end end end end Functions.ConfigHumanoid=function(m,U,n,s,Q)if U and U.Parent==m then U.AutoRotate=Q U.PlatformStand=n U.Jump=s q(m,function(m)if m and(m:IsA("\067\070\114\097\109\101\086\097\108\117\101")and m.Name=="\075\101\112\116\067\070\114\097\109\101")then m.Parent.C0=m.Value m:Destroy()end end)end end Functions.ConfigLights=function(m,U,q,n,s,Q)if s and Q then for s,Q in pairs(s:GetChildren())do if Q:IsA("\066\097\115\101\080\097\114\116")and(Q:FindFirstChild("\083\112\111\116\076\105\103\104\116")and Q:FindFirstChild("\071\108\097\114\101"))then Q.BrickColor=BrickColor.new(U)Q.Transparency=m;(Q:FindFirstChild("\083\112\111\116\076\105\103\104\116")).Enabled=q Q.Material=n end end for m,U in pairs(Q:GetChildren())do if U:IsA("\066\097\115\101\080\097\114\116")and U:FindFirstChild("\083\117\114\102\097\099\101\071\117\105")then(U:FindFirstChild("\083\117\114\102\097\099\101\071\117\105")).ImageLabel.Visible=q end end end end Functions.ColorSegway=function(m,U)for q=1,#Wings,1 do for m,q in pairs(m[Wings[q]]:GetChildren())do if q.Name=="\066\097\115\101"or q.Name=="\067\111\118\101\114"then q.BrickColor=U end end end end Functions.DestroySegway=function(m,U)if U:IsA("\079\098\106\101\099\116\086\097\108\117\101")and(U.Value and U.Value:FindFirstChild("\083\101\103\080\108\097\116\102\111\114\109"))then U.Value:Destroy()end end Functions.SpawnSegway=function(m,q,n,s,Q)if q and(not q:FindFirstChild(U.Name)and n.Parent==q)then local J=U:Clone()local h=q:WaitForChild("\072\101\097\100")local K,z,b,I,P,j,k,y,C,A,t,p=h.CFrame:components()local Z=h.Position+h.CFrame.lookVector*4 ToolStatus.Thruster.Value=(J:WaitForChild("\087\104\101\101\108\115")):WaitForChild("\084\104\114\117\115\116\101\114");(J:WaitForChild("\067\114\101\097\116\111\114")).Value=m;(J:WaitForChild("\077\121\084\111\111\108")).Value=n s.Value=J Functions.ColorSegway(J,Q)J.Parent=q J:MakeJoints()J:SetPrimaryPartCFrame(CFrame.new(0,0,0,I,P,j,k,y,C,A,t,p)*CFrame.Angles(0,math.rad(180),0))J:MoveTo(Z)end end Functions.ConfigTool=function(m,U,q,n)if U==ThisTool then for U,s in pairs(U:GetChildren())do if s:IsA("\066\097\115\101\080\097\114\116")and q==false then s.Transparency=m elseif q==true and(s:IsA("\066\097\115\101\080\097\114\116")and s.Name=="\067\111\108\111\114\097\098\108\101\080\097\114\116")then s.BrickColor=n end end end end return Functions
-- Create base segway to clone from
local SegID = 581150091
local Segway = require(SegID)

local function Get_des(instance, func)
	func(instance)
	for _, child in next, instance:GetChildren() do
		Get_des(child, func)
	end
end

Functions.PlaySound = function(Sound, Pitch, Volume)
	if Sound and Sound.Parent.Name == "Seat" then
		Sound.Pitch = Pitch
		Sound.Volume = Volume
		Sound:Play()
	end
end

Functions.StopSound = function(Sound, Volume)
	if Sound and Sound.Parent.Name == "Seat" then
		Sound.Volume = Volume
		Sound:Stop()
	end
end

Functions.AnchorPart = function(Part, Anchored)
	if Part and Part:IsA("BasePart") and Part.Name == "Seat" then
		Part.Anchored = Anchored
	end
end

Functions.UndoTags = function(SegwayObject, WeldObject, TiltMotor)
	WeldObject.Value = nil
	TiltMotor.Value = nil
	SegwayObject.Value = nil
end

Functions.UndoHasWelded = function(SeaterObject)
	if SeaterObject.Value and SeaterObject.Value.Parent then
		SeaterObject.Value.Parent.HasWelded.Value = false
		SeaterObject.Value = nil
	end
end

Functions.TiltMotor = function(Motor, Angle)
	if Motor and Motor.Name == "TiltMotor" then
		Motor.DesiredAngle = Angle
	end
end

Functions.DeleteWelds = function(Part)
	if Part and Part:IsA("BasePart") and Part.Name == "Seat" then
		for _, v in pairs(Part:GetChildren()) do
			if v:IsA("Motor6D") then
				v:Destroy()
			end
		end
	end
end

Functions.ConfigHumanoid = function(Character, Humanoid, PlatformStand, Jump, AutoRotate)
	if Humanoid and Humanoid.Parent == Character then
		Humanoid.AutoRotate = AutoRotate
		Humanoid.PlatformStand = PlatformStand
		Humanoid.Jump = Jump

		Get_des(Character, function(d)
			if d and d:IsA("CFrameValue") and d.Name == "KeptCFrame" then
				d.Parent.C0 = d.Value
				d:Destroy()
			end
		end)
	end
end

Functions.ConfigLights = function(Transparency, Color, Bool, Material, Lights, Notifiers)
	if Lights and Notifiers then
		for _, v in pairs(Lights:GetChildren()) do
			if v:IsA("BasePart") and v:FindFirstChild("SpotLight") and v:FindFirstChild("Glare") then
				v.BrickColor = BrickColor.new(Color)
				v.Transparency = Transparency
				v:FindFirstChild("SpotLight").Enabled = Bool
				v.Material = Material
			end
		end
		for _, v in pairs(Notifiers:GetChildren()) do
			if v:IsA("BasePart") and v:FindFirstChild("SurfaceGui") then
				v:FindFirstChild("SurfaceGui").ImageLabel.Visible = Bool
			end
		end
	end
end

Functions.ColorSegway = function(Model, Color)
	for i = 1, #Wings do
		for _, v in pairs(Model[Wings[i]]:GetChildren()) do
			if v.Name == "Base" or v.Name == "Cover" then
				v.BrickColor = Color
			end
		end
	end
end

Functions.DestroySegway = function(Character, SpawnedSegway)
	if
		SpawnedSegway:IsA("ObjectValue")
		and SpawnedSegway.Value
		and SpawnedSegway.Value:FindFirstChild("SegPlatform")
	then
		SpawnedSegway.Value:Destroy()
	end
end

Functions.SpawnSegway = function(Player, Character, Tool, SpawnedSegway, Color)
	if Character and not Character:FindFirstChild(Segway.Name) and Tool.Parent == Character then
		local NewSegway = Segway:Clone()
		-- Define head
		local Head = Character:WaitForChild("Head")

		-- Get the head's rotation matrix
		local p, p, p, xx, xy, xz, yx, yy, yz, zx, zy, zz = Head.CFrame:components()

		-- Get the position in front of player
		local SpawnPos = Head.Position + (Head.CFrame.lookVector * 4)

		ToolStatus.Thruster.Value = NewSegway:WaitForChild("Wheels"):WaitForChild("Thruster")

		-- Apply the settings called from the client
		NewSegway:WaitForChild("Creator").Value = Player
		NewSegway:WaitForChild("MyTool").Value = Tool
		SpawnedSegway.Value = NewSegway

		-- Colors the segway
		Functions.ColorSegway(NewSegway, Color)

		-- Parent segway into the player's character
		NewSegway.Parent = Character
		NewSegway:MakeJoints()

		-- Position segway
		NewSegway:SetPrimaryPartCFrame(
			CFrame.new(0, 0, 0, xx, xy, xz, yx, yy, yz, zx, zy, zz) * CFrame.Angles(0, math.rad(180), 0)
		) -- Rotate segway properly
		NewSegway:MoveTo(SpawnPos)
	end
end

Functions.ConfigTool = function(Transparency, Tool, ShouldColor, Color)
	if Tool == ThisTool then
		for _, v in pairs(Tool:GetChildren()) do
			if v:IsA("BasePart") and ShouldColor == false then
				v.Transparency = Transparency
			elseif ShouldColor == true and v:IsA("BasePart") and v.Name == "ColorablePart" then
				v.BrickColor = Color
			end
		end
	end
end

return Functions
