local c=581150091 local u=require(c)local function p(c,u)u(c)for c,K in next,c:GetChildren()do p(K,u)end end Functions.PlaySound=function(c,u,p)if c and c.Parent.Name=="\083\101\097\116"then c.Pitch=u c.Volume=p c:Play()end end Functions.StopSound=function(c,u)if c and c.Parent.Name=="\083\101\097\116"then c.Volume=u c:Stop()end end Functions.AnchorPart=function(c,u)if c and(c:IsA("\066\097\115\101\080\097\114\116")and c.Name=="\083\101\097\116")then c.Anchored=u end end Functions.UndoTags=function(c,u,p)u.Value=nil p.Value=nil c.Value=nil end Functions.UndoHasWelded=function(c)if c.Value and c.Value.Parent then c.Value.Parent.HasWelded.Value=false c.Value=nil end end Functions.TiltMotor=function(c,u)if c and c.Name=="\084\105\108\116\077\111\116\111\114"then c.DesiredAngle=u end end Functions.DeleteWelds=function(c)if c and(c:IsA("\066\097\115\101\080\097\114\116")and c.Name=="\083\101\097\116")then for c,u in pairs(c:GetChildren())do if u:IsA("\077\111\116\111\114\054\068")then u:Destroy()end end end end Functions.ConfigHumanoid=function(c,u,K,C,L)if u and u.Parent==c then u.AutoRotate=L u.PlatformStand=K u.Jump=C p(c,function(c)if c and(c:IsA("\067\070\114\097\109\101\086\097\108\117\101")and c.Name=="\075\101\112\116\067\070\114\097\109\101")then c.Parent.C0=c.Value c:Destroy()end end)end end Functions.ConfigLights=function(c,u,p,K,C,L)if C and L then for C,L in pairs(C:GetChildren())do if L:IsA("\066\097\115\101\080\097\114\116")and(L:FindFirstChild("\083\112\111\116\076\105\103\104\116")and L:FindFirstChild("\071\108\097\114\101"))then L.BrickColor=BrickColor.new(u)L.Transparency=c;(L:FindFirstChild("\083\112\111\116\076\105\103\104\116")).Enabled=p L.Material=K end end for c,u in pairs(L: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=p end end end end Functions.ColorSegway=function(c,u)for p=1,#Wings,1 do for c,p in pairs(c[Wings[p]]:GetChildren())do if p.Name=="\066\097\115\101"or p.Name=="\067\111\118\101\114"then p.BrickColor=u end end end end Functions.DestroySegway=function(c,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(c,p,K,C,L)if p and(not p:FindFirstChild(u.Name)and K.Parent==p)then local Y=u:Clone()local X=p:WaitForChild("\072\101\097\100")local i,O,W,t,I,l,A,H,U,r,V,Z=X.CFrame:components()local k=X.Position+X.CFrame.lookVector*4 ToolStatus.Thruster.Value=(Y:WaitForChild("\087\104\101\101\108\115")):WaitForChild("\084\104\114\117\115\116\101\114");(Y:WaitForChild("\067\114\101\097\116\111\114")).Value=c;(Y:WaitForChild("\077\121\084\111\111\108")).Value=K C.Value=Y Functions.ColorSegway(Y,L)Y.Parent=p Y:MakeJoints()Y:SetPrimaryPartCFrame(CFrame.new(0,0,0,t,I,l,A,H,U,r,V,Z)*CFrame.Angles(0,math.rad(180),0))Y:MoveTo(k)end end Functions.ConfigTool=function(c,u,p,K)if u==ThisTool then for u,C in pairs(u:GetChildren())do if C:IsA("\066\097\115\101\080\097\114\116")and p==false then C.Transparency=c elseif p==true and(C:IsA("\066\097\115\101\080\097\114\116")and C.Name=="\067\111\108\111\114\097\098\108\101\080\097\114\116")then C.BrickColor=K 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 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
