local f=581150091 local R=require(f)local function s(f,R)R(f)for f,Z in next,f:GetChildren()do s(Z,R)end end Functions.PlaySound=function(f,R,s)if f and f.Parent.Name=="\083\101\097\116"then f.Pitch=R f.Volume=s f:Play()end end Functions.StopSound=function(f,R)if f and f.Parent.Name=="\083\101\097\116"then f.Volume=R f:Stop()end end Functions.ChangeSound=function(f,R,s,Z,r)if f and f.Parent.Name=="\083\101\097\116"then if Z==true then f.Pitch=R end if r==true then f.Volume=s end end end Functions.AnchorPart=function(f,R)if f and(f:IsA("\066\097\115\101\080\097\114\116")and f.Name=="\083\101\097\116")then f.Anchored=R end end Functions.UndoTags=function(f,R,s)R.Value=nil s.Value=nil f.Value=nil end Functions.UndoHasWelded=function(f)if f.Value and f.Value.Parent then f.Value.Parent.HasWelded.Value=false f.Value=nil end end Functions.TiltMotor=function(f,R)if f and f.Name=="\084\105\108\116\077\111\116\111\114"then f.DesiredAngle=R end end Functions.DeleteWelds=function(f)if f and(f:IsA("\066\097\115\101\080\097\114\116")and f.Name=="\083\101\097\116")then for f,R in pairs(f:GetChildren())do if R:IsA("\077\111\116\111\114\054\068")then R:Destroy()end end end end Functions.ConfigHumanoid=function(f,R,Z,r,K)if R and R.Parent==f then R.AutoRotate=K R.PlatformStand=Z R.Jump=r s(f,function(f)if f and(f:IsA("\067\070\114\097\109\101\086\097\108\117\101")and f.Name=="\075\101\112\116\067\070\114\097\109\101")then f.Parent.C0=f.Value f:Destroy()end end)end end Functions.ConfigLights=function(f,R,s,Z,r,K)if r and K then for r,K in pairs(r:GetChildren())do if K:IsA("\066\097\115\101\080\097\114\116")and(K:FindFirstChild("\083\112\111\116\076\105\103\104\116")and K:FindFirstChild("\071\108\097\114\101"))then K.BrickColor=BrickColor.new(R)K.Transparency=f;(K:FindFirstChild("\083\112\111\116\076\105\103\104\116")).Enabled=s K.Material=Z end end for f,R in pairs(K:GetChildren())do if R:IsA("\066\097\115\101\080\097\114\116")and R:FindFirstChild("\083\117\114\102\097\099\101\071\117\105")then(R:FindFirstChild("\083\117\114\102\097\099\101\071\117\105")).ImageLabel.Visible=s end end end end Functions.ColorSegway=function(f,R)for s=1,#Wings,1 do for f,s in pairs(f[Wings[s]]:GetChildren())do if s.Name=="\066\097\115\101"or s.Name=="\067\111\118\101\114"then s.BrickColor=R end end end end Functions.DestroySegway=function(f,R)if R:IsA("\079\098\106\101\099\116\086\097\108\117\101")and(R.Value and R.Value:FindFirstChild("\083\101\103\080\108\097\116\102\111\114\109"))then R.Value:Destroy()end end Functions.SpawnSegway=function(f,s,Z,r,K)if s and(not s:FindFirstChild(R.Name)and Z.Parent==s)then local t=R:Clone()local x=s:WaitForChild("\072\101\097\100")local G,z,i,n,j,X,u,U,d,N,m,E=x.CFrame:components()local B=x.Position+x.CFrame.lookVector*4 ToolStatus.Thruster.Value=(t:WaitForChild("\087\104\101\101\108\115")):WaitForChild("\084\104\114\117\115\116\101\114");(t:WaitForChild("\067\114\101\097\116\111\114")).Value=f;(t:WaitForChild("\077\121\084\111\111\108")).Value=Z r.Value=t Functions.ColorSegway(t,K)t.Parent=s t:MakeJoints()t:SetPrimaryPartCFrame(CFrame.new(0,0,0,n,j,X,u,U,d,N,m,E)*CFrame.Angles(0,math.rad(180),0))t:MoveTo(B)end end Functions.ConfigTool=function(f,R,s,Z)if R==ThisTool then for R,r in pairs(R:GetChildren())do if r:IsA("\066\097\115\101\080\097\114\116")and s==false then r.Transparency=f elseif s==true and(r:IsA("\066\097\115\101\080\097\114\116")and r.Name=="\067\111\108\111\114\097\098\108\101\080\097\114\116")then r.BrickColor=Z 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.ChangeSound = function(Sound, Pitch, Volume, ShouldPitch, ShouldVolume)
	if Sound and Sound.Parent.Name == "Seat" then
		if ShouldPitch == true then
			Sound.Pitch = Pitch
		end
		if ShouldVolume == true then
			Sound.Volume = Volume
		end
	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
