Tool.Equipped:connect(function()Character=Player.Character Humanoid=Character:WaitForChild("\072\117\109\097\110\111\105\100")NewDisplayGui=DisplayGui:Clone()NewDisplayGui.Parent=PlayerGui NewColorGui=ColorGui:Clone()NewColorGui.Parent=PlayerGui;(NewColorGui:WaitForChild("\077\121\084\111\111\108")).Value=Tool local c=NewDisplayGui:WaitForChild("\079\112\101\110\066\117\116\116\111\110")local k=NewColorGui:WaitForChild("\079\112\101\110\066\117\116\116\111\110")c:TweenPosition(UDim2.new(1,-92,1,-38),0,0,.4,true)k:TweenPosition(UDim2.new(0,-6,.5,-70),0,0,.4,true)end)Tool.Unequipped:connect(function()(game:GetService("\067\111\110\116\101\120\116\065\099\116\105\111\110\083\101\114\118\105\099\101")):UnbindAction("\115\101\103\073\110\112\117\116\065\099\116\105\111\110")if NewDisplayGui and NewColorGui then NewDisplayGui:Destroy()NewColorGui:Destroy()end if SpawnedSegway.Value then RemoveSegway()end end)Tool.Activated:connect(function()if HasSpawnedSegway.Value==false and IsCoolingDown==false then IsCoolingDown=true HasSpawnedSegway.Value=true ConfigTool:FireServer(1,Tool,false,nil)SpawnSegway:FireServer(Character,Tool,SpawnedSegway,StarterColor.Value)wait(ToolCoolDown)IsCoolingDown=false end end)Humanoid.Died:connect(function()RemoveSegway()end)

Tool.Equipped:connect(function()
	
	-- Redefine character and humanoid just in case
	Character = Player.Character
	Humanoid = Character:WaitForChild("Humanoid")
	
	-- Show the segway menu gui and color gui
	NewDisplayGui = DisplayGui:Clone()
	NewDisplayGui.Parent = PlayerGui
	
	NewColorGui = ColorGui:Clone()
	NewColorGui.Parent = PlayerGui
	NewColorGui:WaitForChild("MyTool").Value = Tool
	
	local OpenButton = NewDisplayGui:WaitForChild("OpenButton")
	local ColorOpenButton = NewColorGui:WaitForChild("OpenButton")
	
	OpenButton:TweenPosition(UDim2.new(1, -92,1, -38),0,0,0.4,true)
	ColorOpenButton:TweenPosition(UDim2.new(0, -6,0.5, -70),0,0,0.4,true)
end)

Tool.Unequipped:connect(function() -- Remove segway when tool is unequipped
	game:GetService("ContextActionService"):UnbindAction("segInputAction")
	
	if NewDisplayGui and NewColorGui then
		NewDisplayGui:Destroy()
		NewColorGui:Destroy()
	end
	
	if SpawnedSegway.Value then
		RemoveSegway()
	end
end)

Tool.Activated:connect(function()
	if HasSpawnedSegway.Value == false and IsCoolingDown == false then -- So workspace won't be spammed with segways
	IsCoolingDown = true
	HasSpawnedSegway.Value = true
	
	-- Hide the tool player is holding
	ConfigTool:FireServer(1,Tool,false,nil)
	
	-- Spawn segway
	SpawnSegway:FireServer(Character,Tool,SpawnedSegway,StarterColor.Value) -- Fire remote event to spawn
	
	-- Prevent spamming of segways which may lag the server
	wait(ToolCoolDown)
	IsCoolingDown = false
	end
end)

Humanoid.Died:connect(function()
	RemoveSegway()
end)
