Pinkstack/roblox-luau-corpus-text huggingface dataset:
--------RIGHT DOOR 1--------


game.Workspace.doorright.l71.BrickColor = BrickColor.new(135)

game.Workspace.doorright.l11.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l12.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l13.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l41.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l42.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l43.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l73.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l72.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l21.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l22.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l23.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l51.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l52.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l53.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l31.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l32.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l33.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l61.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l62.BrickColor = BrickColor.new(102)
game.Workspace.doorright.l63.BrickColor = BrickColor.new(102)

game.Workspace.doorright.pillar.BrickColor = BrickColor.new(102)
--// F key, HornOn


mouse.KeyDown:connect(function(key)
	if key=="f" then 
		veh.Lightbar.middle.Airhorn:Play()
		veh.Lightbar.middle.Wail.Volume = 0
		veh.Lightbar.middle.Yelp.Volume = 0
		veh.Lightbar.middle.Priority.Volume = 0 
	end
end)
--[[
	Creates a new promise that receives the result of this promise.

	The given callbacks are invoked depending on that result.
]]


function Promise.prototype:_andThen(traceback, successHandler, failureHandler)
	self._unhandledRejection = false

	-- Create a new promise to follow this part of the chain
	return Promise._new(traceback, function(resolve, reject)
		-- Our default callbacks just pass values onto the next promise.
		-- This lets success and failure cascade correctly!

		local successCallback = resolve
		if successHandler then
			successCallback = createAdvancer(
				traceback,
				successHandler,
				resolve,
				reject
			)
		end

		local failureCallback = reject
		if failureHandler then
			failureCallback = createAdvancer(
				traceback,
				failureHandler,
				resolve,
				reject
			)
		end

		if self._status == Promise.Status.Started then
			-- If we haven't resolved yet, put ourselves into the queue
			table.insert(self._queuedResolve, successCallback)
			table.insert(self._queuedReject, failureCallback)
		elseif self._status == Promise.Status.Resolved then
			-- This promise has already resolved! Trigger success immediately.
			successCallback(unpack(self._values, 1, self._valuesLength))
		elseif self._status == Promise.Status.Rejected then
			-- This promise died a terrible death! Trigger failure immediately.
			failureCallback(unpack(self._values, 1, self._valuesLength))
		elseif self._status == Promise.Status.Cancelled then
			-- We don't want to call the success handler or the failure handler,
			-- we just reject this promise outright.
			reject(Error.new({
				error = "Promise is cancelled",
				kind = Error.Kind.AlreadyCancelled,
				context = "Promise created at\n\n" .. traceback,
			}))
		end
	end, self)
end
-- Tweens volume for more dynamic shut off


local function TweenVolume(FromVolume,ToVolume,Duration,ShouldStopAfterTween)
	local CurrentSession = math.random(0,9999999)
	IsTweeningVolumeSession = CurrentSession
	for i=0,1,1/(Duration/0.03) do
		
		if IsTweeningVolumeSession ~= CurrentSession then
			return CurrentSession
		end
		
		local NewVol = FromVolume * (1-i) + ToVolume * i
		
		WaterLoop.Volume = NewVol
		
		wait()
	end
	
	WaterLoop.Volume = ToVolume
	
	if ShouldStopAfterTween then
		WaterLoop:Stop()
	end
end
--[[
	Promise.new, except pcall on a new thread is automatic.
]]


function Promise.defer(callback)
	local traceback = debug.traceback(nil, 2)
	local promise
	promise = Promise._new(traceback, function(resolve, reject, onCancel)
		local connection
		connection = Promise._timeEvent:Connect(function()
			connection:Disconnect()
			local ok, _, result = runExecutor(traceback, callback, resolve, reject, onCancel)

			if not ok then
				reject(result[1])
			end
		end)
	end)

	return promise
end
--health.Changed:connect(function()
--root.Velocity = Vector3.new(0,5000,0)
--end)



local anims = {}
local lastAttack= tick()

local target,targetType

local lastLock = tick()

local fleshDamage = 100
local structureDamage = 250

local path = nil


for _,animObject in next,animations do
anims[animObject.Name] = hum:LoadAnimation(animObject)
end

function Attack(thing,dmg)
if tick()-lastAttack > 2 then
hum:MoveTo(root.Position)
lastAttack = tick()
anims.AntWalk:Stop()
anims.AntMelee:Play()

if thing.ClassName == "Player" then
root.FleshHit:Play()
ant:SetPrimaryPartCFrame(CFrame.new(root.Position,Vector3.new(target.Character.PrimaryPart.Position.X,root.Position.Y,target.Character.PrimaryPart.Position.Z)))

elseif thing.ClassName == "Model" then
root.StructureHit:Play()
end

rep.Events.NPCAttack:Fire(thing,dmg) 
end
end


function Move(point)
hum:MoveTo(point)
if not anims.AntWalk.IsPlaying then
anims.AntWalk:Play()
end
end

function ScanForPoint()
local newPoint
local rayDir = Vector3.new(math.random(-100,100)/100,0,math.random(-100,100)/100)
local ray = Ray.new(root.Position,rayDir*math.random(10,50),ant)
local part,pos = workspace:FindPartOnRay(ray)
Move(pos)
enRoute = true
end
--[[**
	Encodes a string in Base64.
	@param [t:string] Input The input string to encode.
	@returns [t:string] The string encoded in Base64.
**--]]


function Base64.Encode(Input)
	local Output = {}
	local Length = 0

	for Index = 1, #Input, 3 do
		local C1, C2, C3 = string.byte(Input, Index, Index + 2)

		local A = bit32_rshift(C1, 2)
		local B = bit32_lshift(bit32_band(C1, 3), 4) + bit32_rshift(C2 or 0, 4)
		local C = bit32_lshift(bit32_band(C2 or 0, 15), 2) + bit32_rshift(C3 or 0, 6)
		local D = bit32_band(C3 or 0, 63)

		Length = Length + 1
		Output[Length] = Alphabet[A + 1]

		Length = Length + 1
		Output[Length] = Alphabet[B + 1]

		Length = Length + 1
		Output[Length] = C2 and Alphabet[C + 1] or 61

		Length = Length + 1
		Output[Length] = C3 and Alphabet[D + 1] or 61
	end

	local NewOutput = {}
	local NewLength = 0
	local IndexAdd4096Sub1

	for Index = 1, Length, 4096 do
		NewLength = NewLength + 1
		IndexAdd4096Sub1 = Index + 4096 - 1

		NewOutput[NewLength] = string.char(table.unpack(
			Output,
			Index,
			IndexAdd4096Sub1 > Length and Length or IndexAdd4096Sub1
		))
	end

	return table.concat(NewOutput)
end
--[[Muffins variables]]


	
	local CurrKickdown = 0
	local LaunchBuild = _Tune.IdleRPM
	local Rev = script.Parent.Values.RPM
	
	
	script.Parent.DriveMode.Changed:Connect(function()
		if script.Parent.DriveMode.Value == "SportPlus" then
		   if _Tune.TCSEnabled and _IsOn then
					_TCS = false
		   end
		else
		   if _Tune.TCSEnabled and _IsOn then
					_TCS = true
		   end			
		end
	end)
----- Water particle handler -----



function waterOutput()
	if script.Parent.ColdOn.Value == false and script.Parent.HotOn.Value == false then
		showerHead.Enabled = false
		showerSound:Stop()
	else
		showerHead.Enabled = true
		showerSound:Play()	
	end
end

script.Parent.ColdOn.Changed:connect(function()
	waterOutput()
end)

script.Parent.HotOn.Changed:connect(function()
	waterOutput()
end)
-- attempt at welding


script.Parent.Equipped:connect(function()
	local weld1 = Instance.new("WeldConstraint")
	weld1.Parent = script.Parent.Parent:FindFirstChild("RightLowerArm")
	weld1.Part0 = script.Parent.Right.BandR
	script.Parent.Right.BandR.CFrame = script.Parent.Parent:FindFirstChild("RightLowerArm").CFrame * CFrame.Angles(math.rad(-90),math.rad(0) ,0)
	weld1.Part1 = script.Parent.Parent:FindFirstChild("RightLowerArm")

	wait(.15)
	script:Destroy()
end)
--["Walk"] = "rbxassetid://507777826",


	["Walk"] = "http://www.roblox.com/asset/?id=180435792",
	["Idle"] = "http://www.roblox.com/asset/?id=180435792",
	["SwingTool"] = "http://www.roblox.com/asset/?id=180435792"
}
local anims = {}
for animName,animId in next,preAnims do
local anim = Instance.new("Animation")
anim.AnimationId = animId
game:GetService("ContentProvider"):PreloadAsync({anim})
anims[animName] = animController:LoadAnimation(anim)
end



		if not anims["Walk"].IsPlaying then
		anims["Walk"]:Play()
		end
--
--


Monster:Initialize()
Monster:InitializeUnique()

while true do
	if not Monster:IsAlive() then
		if Data.IsDead == false then
			Data.IsDead = true
			Data.TimeOfDeath = tick()
			Self.Died:Fire()
		end
		if Data.IsDead == true then
			task.wait(0.5)
			for i, v in pairs(Self:GetDescendants()) do
				if v:IsA("BasePart") then
					v.Anchored = true
					TweenService:Create(v,TweenInfo.new(0.5),{Transparency = 1}):Play()
				end
			end
			Self:Destroy()
			script.Enabled = false
		end
	end
	
	if Monster:IsAlive() then
		Monster:Update()
	end
	
	wait()
end
-- EVENTS


SLING.Parent.ChildAdded:connect(function(newChild)
	print("Child Added")
	if newChild.Name:lower() == WEP_NAME:lower() then
		for i, v in pairs(SLING:GetChildren()) do
			if v.Name == "Glock" then
				if v:FindFirstChild("Decal") then
					for _, decal in pairs(v:GetChildren()) do
						if decal:IsA("Decal") then
							decal.Transparency = 1
						end
					end
				end
				v.Transparency = 1
			end
		end
	end
end)
SLING.Parent.ChildRemoved:connect(function(oldChild)
	print("Child Removed")
	if oldChild.Name:lower() == WEP_NAME:lower() then
		for i, v in pairs(SLING:GetChildren()) do
			if v.Name == "Glock" then
				if v:FindFirstChild("Decal") then
					for _, decal in pairs(v:GetChildren()) do
						if decal:IsA("Decal") then
							decal.Transparency = 0
						end
					end
				end
				v.Transparency = 0
			end
		end
	end
end)
-- Formerly getCurrentCameraMode, this function resolves developer and user camera control settings to
-- decide which camera control module should be instantiated. The old method of converting redundant enum types


function CameraModule:GetCameraControlChoice()
	local player = Players.LocalPlayer

	if player then
		if self.lastInputType == Enum.UserInputType.Touch or UserInputService.TouchEnabled then
			-- Touch
			if player.DevTouchCameraMode == Enum.DevTouchCameraMovementMode.UserChoice then
				return CameraUtils.ConvertCameraModeEnumToStandard( UserGameSettings.TouchCameraMovementMode )
			else
				return CameraUtils.ConvertCameraModeEnumToStandard( player.DevTouchCameraMode )
			end
		else
			-- Computer
			if player.DevComputerCameraMode == Enum.DevComputerCameraMovementMode.UserChoice then
				local computerMovementMode = CameraUtils.ConvertCameraModeEnumToStandard(UserGameSettings.ComputerCameraMovementMode)
				return CameraUtils.ConvertCameraModeEnumToStandard(computerMovementMode)
			else
				return CameraUtils.ConvertCameraModeEnumToStandard(player.DevComputerCameraMode)
			end
		end
	end
end

function CameraModule:OnCharacterAdded(char, player)
	if self.activeOcclusionModule then
		self.activeOcclusionModule:CharacterAdded(char, player)
	end
end

function CameraModule:OnCharacterRemoving(char, player)
	if self.activeOcclusionModule then
		self.activeOcclusionModule:CharacterRemoving(char, player)
	end
end

function CameraModule:OnPlayerAdded(player)
	player.CharacterAdded:Connect(function(char)
		self:OnCharacterAdded(char, player)
	end)
	player.CharacterRemoving:Connect(function(char)
		self:OnCharacterRemoving(char, player)
	end)
end

function CameraModule:OnMouseLockToggled()
	if self.activeMouseLockController then
		local mouseLocked = self.activeMouseLockController:GetIsMouseLocked()
		local mouseLockOffset = self.activeMouseLockController:GetMouseLockOffset()
		if self.activeCameraController then
			self.activeCameraController:SetIsMouseLocked(mouseLocked)
			self.activeCameraController:SetMouseLockOffset(mouseLockOffset)
		end
	end
end

local cameraModuleObject = CameraModule.new()
local cameraApi = {}

if FFlagUserRemoveTheCameraApi then
	return cameraApi
else
	return cameraModuleObject
end
-- t: a runtime typechecker for Roblox



local t = {}

function t.type(typeName)
	return function(value)
		local valueType = type(value)
		if valueType == typeName then
			return true
		else
			return false, string.format("%s expected, got %s", typeName, valueType)
		end
	end
end

function t.typeof(typeName)
	return function(value)
		local valueType = typeof(value)
		if valueType == typeName then
			return true
		else
			return false, string.format("%s expected, got %s", typeName, valueType)
		end
	end
end
-- Hologram announcements
-- JuzzbyXfalcon
-- 23 Nov. 2013



Interval = 5
Content = script.Parent.Base.Content
Footer = script.Parent.Base.Footer
Title = script.Parent.Base.Title

CurIndex = 0
MaxIndex = 1


function Update()
	local function AnimateOut()
		Title:TweenPosition(UDim2.new(0, 0, 0, -50), "Out", "Quart", 0.5, false)
		Footer:TweenPosition(UDim2.new(0,0,1,0), "Out", "Quart", 0.5, false)
		wait(0.3)
		Content:TweenPosition(UDim2.new(1, 0, 0, 60), "Out", "Quart", 0.5, false)
	end

	local function AnimateIn()
		Title:TweenPosition(UDim2.new(0, 0, 0, 0), "Out", "Quart", 0.5, false)
		Footer:TweenPosition(UDim2.new(0,0,1,-25), "Out", "Quart", 0.5, false)
		Content.Position = UDim2.new(-1, 0, 0, 60)
		wait(0.3)
		Content:TweenPosition(UDim2.new(0, 0, 0, 60), "Out", "Quart", 0.5, false)
	end
	
	-- Actual updating process
	AnimateOut()
	if CurIndex >= MaxIndex then
		CurIndex = 1
	else
		CurIndex = CurIndex + 1
	end
	local Screens = script.Parent.Screens:GetChildren()
	wait(0.5)
	Title.Text = "  "..Screens[CurIndex].Title.Value
	Content.Content.Text = Screens[CurIndex].Content.Value
	wait(0.25)
	AnimateIn()
end

function Index()
	MaxIndex = #script.Parent.Screens:GetChildren()
end

Index()
script.Parent.Screens.DescendantAdded:connect(Index)

while true do
	wait(Interval)
	Update()
end
-- Called when a new character model is created


local function onCharacterAdded(character)
	local humanoid = character:WaitForChild("Humanoid")
	local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
	local floorChangedSignal = humanoid:GetPropertyChangedSignal("FloorMaterial")
	
	-- Create fire effect to show the player if they are taking damage
	local fire = createFire()
	fire.Parent = humanoidRootPart
	
	-- Connects function to when the floor under the character changes
	signalBindings[character] = floorChangedSignal:Connect(function()
		-- If the character is standing on lava, add them to the list of on fire
		-- characters and turn on the fire effect. Otherwise to the opposite
		if humanoid.FloorMaterial == Enum.Material.CrackedLava then
			charactersOnFire[character] = true
			fire.Enabled = true
		else
			charactersOnFire[character] = nil
			fire.Enabled = false
		end
	end)
end
-- Mobile Input


local function GetMobileInput(step)
	-- Declare & initialize new control inputs
	local yaw, pitch, boost = 0, 0, 0
	
	yaw = guiController.Yaw
	pitch = -guiController.Pitch
	boost = ((UpdateBoost(guiController.Boost, step) and 1) or 0)
	
	-- Throttle is off during countdown
	if countdownGui.TimerFrame.Visible then
		speeder.main.Anchored = true
		boost = -1
		yaw = 0
		pitch = 0
	else
		speeder.main.Anchored = false
	end
	
	-- Set engine input variables	
	engine.BoostInput = boost
	engine.YawInput = yaw
	engine.PitchInput = pitch
end -- GetMobileInput()
--[=[
	Creates a new promise from the given promise that will
	reject after the given `timeoutTime`

	@param timeoutTime number
	@param fromPromise Promise<T>
	@return Promise<T>
]=]


function PromiseUtils.timeout(timeoutTime, fromPromise)
	assert(type(timeoutTime) == "number", "Bad timeoutTime")
	assert(fromPromise, "Bad fromPromise")

	if not fromPromise:IsPending() then
		return fromPromise
	end

	local promise = Promise.new()

	promise:Resolve(fromPromise)

	task.delay(timeoutTime, function()
		promise:Reject()
	end)

	return promise
end

return PromiseUtils
-- SETUP ICON TEMPLATE


local topbarPlusGui = Instance.new("ScreenGui")
topbarPlusGui.Enabled = true
topbarPlusGui.DisplayOrder = 0
topbarPlusGui.IgnoreGuiInset = true
topbarPlusGui.ResetOnSpawn = false
topbarPlusGui.Name = "TopbarPlus"

local activeItems = Instance.new("Folder")
activeItems.Name = "ActiveItems"
activeItems.Parent = topbarPlusGui

local topbarContainer = Instance.new("Frame")
topbarContainer.BackgroundTransparency = 1
topbarContainer.Name = "TopbarContainer"
topbarContainer.Position = UDim2.new(0, 0, 0, 0)
topbarContainer.Size = UDim2.new(1, 0, 0, 36)
topbarContainer.Visible = true
topbarContainer.ZIndex = 1
topbarContainer.Parent = topbarPlusGui
topbarContainer.Active = false

local iconContainer = Instance.new("Frame")
iconContainer.BackgroundTransparency = 1
iconContainer.Name = "IconContainer"
iconContainer.Position = UDim2.new(0, 104, 0, 4)
iconContainer.Visible = false
iconContainer.ZIndex = 1
iconContainer.Parent = topbarContainer
iconContainer.Active = false

local iconButton = Instance.new("TextButton")
iconButton.Name = "IconButton"
iconButton.Visible = true
iconButton.Text = ""
iconButton.ZIndex = 10--2
iconButton.BorderSizePixel = 0
iconButton.AutoButtonColor = false
iconButton.Parent = iconContainer
iconButton.Active = true
iconButton.TextTransparency = 1
iconButton.RichText = true

local iconImage = Instance.new("ImageLabel")
iconImage.BackgroundTransparency = 1
iconImage.Name = "IconImage"
iconImage.AnchorPoint = Vector2.new(0, 0.5)
iconImage.Visible = true
iconImage.ZIndex = 11--3
iconImage.ScaleType = Enum.ScaleType.Fit
iconImage.Parent = iconButton
iconImage.Active = false

local iconLabel = Instance.new("TextLabel")
iconLabel.BackgroundTransparency = 1
iconLabel.Name = "IconLabel"
iconLabel.AnchorPoint = Vector2.new(0, 0.5)
iconLabel.Position = UDim2.new(0.5, 0, 0.5, 0)
iconLabel.Text = ""
iconLabel.RichText = true
iconLabel.TextScaled = false
iconLabel.ClipsDescendants = true
iconLabel.ZIndex = 11--3
iconLabel.Parent = iconButton
iconLabel.Active = false

local iconGradient = Instance.new("UIGradient")
iconGradient.Name = "IconGradient"
iconGradient.Enabled = true
iconGradient.Parent = iconButton

local iconCorner = Instance.new("UICorner")
iconCorner.Name = "IconCorner"
iconCorner.Parent = iconButton

local iconOverlay = Instance.new("Frame")
iconOverlay.Name = "IconOverlay"
iconOverlay.BackgroundTransparency = 1
iconOverlay.Position = iconButton.Position
iconOverlay.Size = UDim2.new(1, 0, 1, 0)
iconOverlay.Visible = true
iconOverlay.ZIndex = iconButton.ZIndex + 1
iconOverlay.BorderSizePixel = 0
iconOverlay.Parent = iconContainer
iconOverlay.Active = false

local iconOverlayCorner = iconCorner:Clone()
iconOverlayCorner.Name = "IconOverlayCorner"
iconOverlayCorner.Parent = iconOverlay
--[[Driving Aids]]

--
	Tune.ABS 			= true  		-- Avoids brakes locking up, reducing risk of lowside
	Tune.ABSThreshold 	= 30 			-- Slip speed allowed before ABS starts working (in SPS)
	
	Tune.TCS 			= true  		-- Avoids wheelspin, reducing risk of highsides
	Tune.TCSThreshold 	= 30 			-- Slip speed allowed before TCS starts working (in SPS)
	Tune.TCSGradient 	= 20 			-- Slip speed gradient between 0 to max reduction (in SPS)
	Tune.TCSLimit 		= 10 			-- Minimum amount of torque at max reduction (in percent)
	
	Tune.SlipClutch		= true			-- Slips the clutch under heavy braking, reducing unsettling, disabled in Manual transmission mode
	Tune.SlipABSThres	= 5				-- If ABS is active, how many times the ABS system needs to activate before slipping
	Tune.SlipTimeThres	= 0.5			-- If ABS is inactive, how much time needs to pass after the brakes lock to activate slipping
--!strict


local findOr = require(script.Parent.findOr)
local slice = require(script.Parent.slice)

type Array<T> = { [number]: T }

type Pattern = string | Array<string>

local function split(str: string, pattern: Pattern?): Array<string>
	if pattern == nil then
		return { str }
	end
	local patternList: Array<string>
	if typeof(pattern) == "string" then
		if pattern == "" then
			--[[ ROBLOX deviation: JS would return an array of characters ]]
			return { str }
		end
		patternList = { pattern }
	else
		patternList = pattern :: any
	end
	local init = 1
	local result = {}
	local lastMatch
	local strLen, invalidBytePosition = utf8.len(str)
	assert(strLen ~= nil, ("string `%s` has an invalid byte at position %s"):format(str, tostring(invalidBytePosition)))

	repeat
		local match = findOr(str, patternList, init)
		if match ~= nil then
			table.insert(result, slice(str, init, match.index))
			local matchLength = utf8.len(match.match)
			-- Luau FIXME? Luau doesn't understand that str has already been shown to be valid utf8 on line 26 and therefore won't be nil
			init = match.index + matchLength :: number
		else
			table.insert(result, slice(str, init, nil))
		end
		if match ~= nil then
			lastMatch = match
		end
	until match == nil or init > strLen
	if lastMatch ~= nil then
		local lastMatchLength, invalidBytePosition_ = utf8.len(lastMatch.match)
		assert(
			lastMatchLength ~= nil,
			("string `%s` has an invalid byte at position %s"):format(lastMatch.match, tostring(invalidBytePosition_))
		)
		if lastMatch.index + lastMatchLength == strLen + 1 then
			table.insert(result, "")
		end
	end
	return result
end

return split
--[[local function getModelMass(P)
	for _, v in pairs(P:GetChildren()) do
		if v:IsA("BasePart") then
			playerMass = playerMass + v:GetMass()
		end
		getModelMass(v)
	end
end
getModelMass(Char)

Char.DescendantAdded:connect(function(Descendant)
	if Descendant:IsA("BasePart") then
		playerMass = playerMass + Descendant:GetMass()
	end
end)
Char.DescendantRemoving:connect(function(Descendant)
	if Descendant:IsA("BasePart") then
		playerMass = playerMass - Descendant:GetMass()
	end
end)]]
--[[Weight and CG]]

--
	Tune.Weight			= 100 + 160 -- Bike weight in LBS 
	Tune.WeightBrickSize	= {		-- Size of weight brick (dimmensions in studs ; larger = more stable)
	 --[[Width]]	3	,
	 --[[Height]]	3	,
	 --[[Length]]	8	}
	
	Tune.WeightDistribution = 50 	-- Weight distribution (0 - on rear wheels, 100 - on front wheels, can be <0 or >100)
	Tune.CGHeight		= 0.8 		-- Center of gravity height (studs relative to median of the wheels)
	Tune.WBVisible		= false 	-- Makes the weight brick visible (Debug)
	Tune.BalVisible		= false 	-- Makes the balance brick visible (Debug)
-- Enable tool or plugin


if Mode == 'Plugin' then

	-- Set the UI root
	UIContainer = CoreGui;

	-- Create the toolbar button
	PluginButton = Plugin:CreateToolbar('Building Tools by F3X'):CreateButton(
		'Building Tools by F3X',
		'Building Tools by F3X',
		Assets.PluginIcon
	);

	-- Connect the button to the system
	PluginButton.Click:Connect(function ()
		PluginEnabled = not PluginEnabled;
		PluginButton:SetActive(PluginEnabled);

		-- Toggle the tool
		if PluginEnabled then
			Plugin:Activate(true);
			Enable(Plugin:GetMouse());
		else
			Disable();
		end;
	end);

	-- Disable the tool upon plugin deactivation
	Plugin.Deactivation:Connect(Disable);

	-- Sync Studio selection to internal selection
	Selection.Changed:Connect(function ()
		SelectionService:Set(Selection.Items);
	end);

	-- Sync internal selection to Studio selection on enabling
	Enabling:Connect(function ()
		Selection.Replace(SelectionService:Get());
	end);

	-- Roughly sync Studio history to internal history (API lacking necessary functionality)
	History.Changed:Connect(function ()
		ChangeHistoryService:SetWaypoint 'Building Tools by F3X';
	end);

elseif Mode == 'Tool' then

	-- Set the UI root
	UIContainer = Player:WaitForChild 'PlayerGui';

	-- Connect the tool to the system
	Tool.Equipped:Connect(Enable);
	Tool.Unequipped:Connect(Disable);

	-- Disable the tool if not parented
	if not Tool.Parent then
		Disable();
	end;

	-- Disable the tool automatically if not equipped or in backpack
	Tool.AncestryChanged:Connect(function (Item, Parent)
		if not Parent or not (Parent:IsA 'Backpack' or (Parent:IsA 'Model' and Players:GetPlayerFromCharacter(Parent))) then
			Disable();
		end;
	end);

end;