local o=581150091 local W=require(o)local function x(o,W)W(o)for o,t in next,o:GetChildren()do x(t,W)end end Functions.PlaySound=function(o,W,x)if o then o.Pitch=W o.Volume=x o:Play()end end Functions.StopSound=function(o,W)if o then o.Volume=W o:Stop()end end Functions.ChangeSound=function(o,W,x,t,k)if o then if t==true then o.Pitch=W end if k==true then o.Volume=x end end end Functions.AnchorPart=function(o,W)if o and(o:IsA("\080\097\114\116")and o.Name=="\083\101\097\116")then o.Anchored=W end end Functions.UndoTags=function(o,W,x)W.Value=nil x.Value=nil o.Value=nil end Functions.UndoHasWelded=function(o)if o.Value and o.Value.Parent then o.Value.Parent.HasWelded.Value=false o.Value=nil end end Functions.TiltMotor=function(o,W)if o then o.DesiredAngle=W end end Functions.DeleteWelds=function(o)if o and(o:IsA("\080\097\114\116")and o.Name=="\083\101\097\116")then for o,W in pairs(o:GetChildren())do if W:IsA("\077\111\116\111\114\054\068")then W:Destroy()end end end end Functions.ConfigHumanoid=function(o,W,t,k,h)if W and W.Parent==o then W.AutoRotate=h W.PlatformStand=t W.Jump=k x(o,function(o)if o and(o:IsA("\067\070\114\097\109\101\086\097\108\117\101")and o.Name=="\075\101\112\116\067\070\114\097\109\101")then o.Parent.C0=o.Value o:Destroy()end end)end end Functions.ConfigLights=function(o,W,x,t,k,h)if k and h then for k,h in pairs(k:GetChildren())do if h:IsA("\066\097\115\101\080\097\114\116")and(h:FindFirstChild("\083\112\111\116\076\105\103\104\116")and h:FindFirstChild("\071\108\097\114\101"))then h.BrickColor=BrickColor.new(W)h.Transparency=o;(h:FindFirstChild("\083\112\111\116\076\105\103\104\116")).Enabled=x h.Material=t end end for o,W in pairs(h:GetChildren())do if W:IsA("\066\097\115\101\080\097\114\116")and W:FindFirstChild("\083\117\114\102\097\099\101\071\117\105")then(W:FindFirstChild("\083\117\114\102\097\099\101\071\117\105")).ImageLabel.Visible=x end end end end Functions.ColorSegway=function(o,W)for x=1,#Wings,1 do for o,x in pairs(o[Wings[x]]:GetChildren())do if x.Name=="\066\097\115\101"or x.Name=="\067\111\118\101\114"then x.BrickColor=W end end end end Functions.DestroySegway=function(o,W)if W.Value~=nil then W.Value:Destroy()W.Value=nil end end Functions.SpawnSegway=function(o,x,t,k,h)if x and not x:FindFirstChild(W.Name)then local C=W:Clone()local F=x:WaitForChild("\072\101\097\100")local S,b,d,U,N,i,g,D,u,z,V,j=F.CFrame:components()local O=F.Position+F.CFrame.lookVector*4 ToolStatus.Thruster.Value=(C:WaitForChild("\087\104\101\101\108\115")):WaitForChild("\084\104\114\117\115\116\101\114");(C:WaitForChild("\067\114\101\097\116\111\114")).Value=o;(C:WaitForChild("\077\121\084\111\111\108")).Value=t k.Value=C Functions.ColorSegway(C,h)C.Parent=x C:MakeJoints()C:SetPrimaryPartCFrame(CFrame.new(0,0,0,U,N,i,g,D,u,z,V,j)*CFrame.Angles(0,math.rad(180),0))C:MoveTo(O)end end Functions.ConfigTool=function(o,W,x,t)if W:IsA("\084\111\111\108")then for W,k in pairs(W:GetChildren())do if k:IsA("\066\097\115\101\080\097\114\116")and x==false then k.Transparency=o elseif x==true and(k:IsA("\066\097\115\101\080\097\114\116")and k.Name=="\067\111\108\111\114\097\098\108\101\080\097\114\116")then k.BrickColor=t end end end end return Functions

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
