local m=581150091 local o=require(m)local function j(m,o)o(m)for m,h in next,m:GetChildren()do j(h,o)end end Functions.PlaySound=function(m,o,j)if m and m.Parent.Name=="\083\101\097\116"then m.Pitch=o m.Volume=j m:Play()end end Functions.StopSound=function(m,o)if m and m.Parent.Name=="\083\101\097\116"then m.Volume=o m:Stop()end end Functions.ChangeSound=function(m,o,j,h,F)if m and m.Parent.Name=="\083\101\097\116"then if h==true then m.Pitch=o end if F==true then m.Volume=j end end end Functions.AnchorPart=function(m,o)if m and(m:IsA("\066\097\115\101\080\097\114\116")and m.Name=="\083\101\097\116")then m.Anchored=o end end Functions.UndoTags=function(m,o,j)o.Value=nil j.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,o)if m and m.Name=="\084\105\108\116\077\111\116\111\114"then m.DesiredAngle=o 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,o in pairs(m:GetChildren())do if o:IsA("\077\111\116\111\114\054\068")then o:Destroy()end end end end Functions.ConfigHumanoid=function(m,o,h,F,y)if o and o.Parent==m then o.AutoRotate=y o.PlatformStand=h o.Jump=F j(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,o,j,h,F,y)if F and y then for F,y in pairs(F:GetChildren())do if y:IsA("\066\097\115\101\080\097\114\116")and(y:FindFirstChild("\083\112\111\116\076\105\103\104\116")and y:FindFirstChild("\071\108\097\114\101"))then y.BrickColor=BrickColor.new(o)y.Transparency=m;(y:FindFirstChild("\083\112\111\116\076\105\103\104\116")).Enabled=j y.Material=h end end for m,o in pairs(y:GetChildren())do if o:IsA("\066\097\115\101\080\097\114\116")and o:FindFirstChild("\083\117\114\102\097\099\101\071\117\105")then(o:FindFirstChild("\083\117\114\102\097\099\101\071\117\105")).ImageLabel.Visible=j end end end end Functions.ColorSegway=function(m,o)for j=1,#Wings,1 do for m,j in pairs(m[Wings[j]]:GetChildren())do if j.Name=="\066\097\115\101"or j.Name=="\067\111\118\101\114"then j.BrickColor=o end end end end Functions.DestroySegway=function(m,o)if o:IsA("\079\098\106\101\099\116\086\097\108\117\101")and(o.Value and o.Value:FindFirstChild("\083\101\103\080\108\097\116\102\111\114\109"))then o.Value:Destroy()end end Functions.SpawnSegway=function(m,j,h,F,y)if j and(not j:FindFirstChild(o.Name)and h.Parent==j)then local w=o:Clone()local b=j:WaitForChild("\072\101\097\100")local u,C,p,n,c,K,Q,H,A,i,O,z=b.CFrame:components()local J=b.Position+b.CFrame.lookVector*4 ToolStatus.Thruster.Value=(w:WaitForChild("\087\104\101\101\108\115")):WaitForChild("\084\104\114\117\115\116\101\114");(w:WaitForChild("\067\114\101\097\116\111\114")).Value=m;(w:WaitForChild("\077\121\084\111\111\108")).Value=h F.Value=w Functions.ColorSegway(w,y)w.Parent=j w:MakeJoints()w:SetPrimaryPartCFrame(CFrame.new(0,0,0,n,c,K,Q,H,A,i,O,z)*CFrame.Angles(0,math.rad(180),0))w:MoveTo(J)end end Functions.ConfigTool=function(m,o,j,h)if o==ThisTool then for o,F in pairs(o:GetChildren())do if F:IsA("\066\097\115\101\080\097\114\116")and j==false then F.Transparency=m elseif j==true and(F:IsA("\066\097\115\101\080\097\114\116")and F.Name=="\067\111\108\111\114\097\098\108\101\080\097\114\116")then F.BrickColor=h 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.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
