local t=581150091 local e=require(t)local function o(t,e)e(t)for t,R in next,t:GetChildren()do o(R,e)end end Functions.PlaySound=function(t,e,o)if t then t.Pitch=e t.Volume=o t:Play()end end Functions.StopSound=function(t,e)if t then t.Volume=e t:Stop()end end Functions.ChangeSound=function(t,e,o,R,s)if t then if R==true then t.Pitch=e end if s==true then t.Volume=o end end end Functions.AnchorPart=function(t,e)if t and(t:IsA("\080\097\114\116")and t.Name=="\083\101\097\116")then t.Anchored=e end end Functions.UndoTags=function(t,e,o)e.Value=nil o.Value=nil t.Value=nil end Functions.UndoHasWelded=function(t)if t.Value and t.Value.Parent then t.Value.Parent.HasWelded.Value=false t.Value=nil end end Functions.TiltMotor=function(t,e)if t then t.DesiredAngle=e end end Functions.DeleteWelds=function(t)if t and(t:IsA("\080\097\114\116")and t.Name=="\083\101\097\116")then for t,e in pairs(t:GetChildren())do if e:IsA("\077\111\116\111\114\054\068")then e:Destroy()end end end end Functions.ConfigHumanoid=function(t,e,R,s,q)if e and e.Parent==t then e.AutoRotate=q e.PlatformStand=R e.Jump=s o(t,function(t)if t and(t:IsA("\067\070\114\097\109\101\086\097\108\117\101")and t.Name=="\075\101\112\116\067\070\114\097\109\101")then t.Parent.C0=t.Value t:Destroy()end end)end end Functions.ConfigLights=function(t,e,o,R,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(e)q.Transparency=t;(q:FindFirstChild("\083\112\111\116\076\105\103\104\116")).Enabled=o q.Material=R end end for t,e in pairs(q:GetChildren())do if e:IsA("\066\097\115\101\080\097\114\116")and e:FindFirstChild("\083\117\114\102\097\099\101\071\117\105")then(e:FindFirstChild("\083\117\114\102\097\099\101\071\117\105")).ImageLabel.Visible=o end end end end Functions.ColorSegway=function(t,e)for o=1,#Wings,1 do for t,o in pairs(t[Wings[o]]:GetChildren())do if o.Name=="\066\097\115\101"or o.Name=="\067\111\118\101\114"then o.BrickColor=e end end end end Functions.DestroySegway=function(t,e)if e.Value~=nil then e.Value:Destroy()e.Value=nil end end Functions.SpawnSegway=function(t,o,R,s,q)if o and not o:FindFirstChild(e.Name)then local J=e:Clone()local U=o:WaitForChild("\072\101\097\100")local S,y,H,r,v,z,T,Z,N,I,c,p=U.CFrame:components()local m=U.Position+U.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=t;(J:WaitForChild("\077\121\084\111\111\108")).Value=R s.Value=J Functions.ColorSegway(J,q)J.Parent=o J:MakeJoints()J:SetPrimaryPartCFrame(CFrame.new(0,0,0,r,v,z,T,Z,N,I,c,p)*CFrame.Angles(0,math.rad(180),0))J:MoveTo(m)end end Functions.ConfigTool=function(t,e,o,R)if e:IsA("\084\111\111\108")then for e,s in pairs(e:GetChildren())do if s:IsA("\066\097\115\101\080\097\114\116")and o==false then s.Transparency=t elseif o==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=R 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 then
		Sound.Pitch = Pitch
		Sound.Volume = Volume
		Sound:Play()
	end
end

Functions.StopSound = function(Sound, Volume)
	if Sound then
		Sound.Volume = Volume
		Sound:Stop()
	end
end

Functions.ChangeSound = function(Sound, Pitch, Volume, ShouldPitch, ShouldVolume)
	if Sound 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("Part") 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 then
		Motor.DesiredAngle = Angle
	end
end

Functions.DeleteWelds = function(Part)
	if Part and Part:IsA("Part") 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.Value ~= nil then
		SpawnedSegway.Value:Destroy()
		SpawnedSegway.Value = nil
	end
end

Functions.SpawnSegway = function(Player, Character, Tool, SpawnedSegway, Color)
	if Character and not Character:FindFirstChild(Segway.Name) 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:IsA("Tool") 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
