Pinkstack/roblox-luau-corpus-text huggingface dataset:
-- If in-game, enable ctrl hotkeys for exporting


if Mode == 'Tool' then
	AssignHotkey({ 'LeftControl', 'P' }, ExportSelection);
	AssignHotkey({ 'RightControl', 'P' }, ExportSelection);
end;

function IsVersionOutdated()
	-- Returns whether this version of Building Tools is out of date

	-- Check most recent version number
	local AssetInfo = MarketplaceService:GetProductInfo(142785488, Enum.InfoType.Asset);
	local LatestMajorVersion, LatestMinorVersion, LatestPatchVersion = AssetInfo.Description:match '%[Version: ([0-9]+)%.([0-9]+)%.([0-9]+)%]';
	local CurrentMajorVersion, CurrentMinorVersion, CurrentPatchVersion = Tool.Version.Value:match '([0-9]+)%.([0-9]+)%.([0-9]+)';

	-- Convert version data into numbers
	local LatestMajorVersion, LatestMinorVersion, LatestPatchVersion =
		tonumber(LatestMajorVersion), tonumber(LatestMinorVersion), tonumber(LatestPatchVersion);
	local CurrentMajorVersion, CurrentMinorVersion, CurrentPatchVersion =
		tonumber(CurrentMajorVersion), tonumber(CurrentMinorVersion), tonumber(CurrentPatchVersion);

	-- Determine whether current version is outdated
	if LatestMajorVersion > CurrentMajorVersion then
		return true;
	elseif LatestMajorVersion == CurrentMajorVersion then
		if LatestMinorVersion > CurrentMinorVersion then
			return true;
		elseif LatestMinorVersion == CurrentMinorVersion then
			return LatestPatchVersion > CurrentPatchVersion;
		end;
	end;

	-- Return an up-to-date status if not oudated
	return false;

end;

function ToggleSwitch(CurrentButtonName, SwitchContainer)
	-- Toggles between the buttons in a switch

	-- Reset all buttons
	for _, Button in pairs(SwitchContainer:GetChildren()) do

		-- Make sure to not mistake the option label for a button
		if Button.Name ~= 'Label' then

			-- Set appearance to disabled
			Button.SelectedIndicator.BackgroundTransparency = 1;
			Button.Background.Image = Assets.LightSlantedRectangle;

		end;

	end;

	-- Make sure there's a new current button
	if CurrentButtonName then

		-- Get the current button
		local CurrentButton = SwitchContainer[CurrentButtonName];

		-- Set the current button's appearance to enabled
		CurrentButton.SelectedIndicator.BackgroundTransparency = 0;
		CurrentButton.Background.Image = Assets.DarkSlantedRectangle;

	end;
end;
--[[Drivetrain]]

	
	Tune.Config			= "RWD"		--"FWD" , "RWD" , "AWD"
	
	--Differential Settings	
	Tune.FDiffSlipThres	= 50		-- 1 - 100%				(Max threshold of applying full lock determined by deviation from avg speed)
	Tune.FDiffLockThres	= 50		-- 0 - 100%				(0 - Bias toward slower wheel, 100 - Bias toward faster wheel)
	Tune.RDiffSlipThres	= 50		-- 1 - 100%
	Tune.RDiffLockThres	= 50		-- 0 - 100%
	Tune.CDiffSlipThres	= 50		-- 1 - 100%				[AWD Only]
	Tune.CDiffLockThres	= 50		-- 0 - 100%				[AWD Only]
	
	--Traction Control Settings
	Tune.TCSEnabled		= true		-- Implements TCS
	Tune.TCSThreshold	= 0	    	-- Slip speed allowed before TCS starts working (in SPS)
	Tune.TCSGradient	= 10      	-- Slip speed gradient between 0 to max reduction (in SPS)
	Tune.TCSLimit		= 10		-- Minimum amount of torque at max reduction (in percent)
--| Main |--


Remote.PhongDev.OnServerEvent:Connect(function(LocalPlayer)
	
	--| Clone |--
	local Emit_VFX = Access.VFX.In_Transform.Emit_VFX:Clone()
	Emit_VFX.Parent = LocalPlayer.Character.PrimaryPart
	Debris:AddItem(Emit_VFX, 5)
	
	local Emit_VFX2 = Access.VFX.In_Transform.Emit_VFX2:Clone()
	Emit_VFX2.Parent = LocalPlayer.Character.PrimaryPart
	Debris:AddItem(Emit_VFX2, 4)
	
	local Enabled_VFX = Access.VFX.In_Transform.Enabled_VFX:Clone()
	Enabled_VFX.Parent = LocalPlayer.Character.PrimaryPart
	Debris:AddItem(Enabled_VFX, 4)
	
	spawn(function()
		for i,v in pairs(Enabled_VFX:GetChildren()) do
			v.Enabled = true
		end
	end)
	
	
	delay(0.2,function()
	for i,v in pairs(Emit_VFX:GetChildren()) do
		v:Emit(v:GetAttribute("EmitCount"))
	end
	wait(2.05)
	for i,v in pairs(Emit_VFX2:GetChildren()) do
		v:Emit(v:GetAttribute("EmitCount"))
		end
	end)
	
	delay(2.05,function()
		local Transform = Access.VFX.Transform:Clone()
		Transform.Parent = LocalPlayer.Character.PrimaryPart
		Debris:AddItem(Transform, 4)
		
		local WeldPart = Instance.new("Weld", LocalPlayer.Character.PrimaryPart)
		WeldPart.Part0 = LocalPlayer.Character.PrimaryPart
		WeldPart.Part1 = Transform
		WeldPart.C0 = WeldPart.Part0.CFrame:ToObjectSpace(WeldPart.Part1.CFrame * CFrame.new(0,0,0))
		Debris:AddItem(WeldPart,4)
		
		for i,v in pairs(Transform.Emit_VFX:GetChildren()) do
			v:Emit(v:GetAttribute("EmitCount"))
		end
		wait(0.7)
		
		Transform.Bone:Destroy()
		
		for i,v in pairs(Transform.Enabled_VFX:GetChildren()) do
			v.Enabled = false
		end
	end)
	
	delay(4,function()
		local Body = Access.VFX.Body.VFX:Clone()
		Body.Parent = LocalPlayer.Character.PrimaryPart
		Debris:AddItem(Body, Cooldown.Value)
		
		wait(Cooldown.Value - 0.5)
		
		for i,v in pairs(Body:GetChildren()) do
			v.Enabled = false
		end
	end)
	
end)
--[=[
	Constructs a new service.

	:::caution
	Services must be created _before_ calling `Knit.Start()`.
	:::
	```lua
	-- Create a service
	local MyService = Knit.CreateService {
		Name = "MyService",
		Client = {},
	}

	-- Expose a ToAllCaps remote function to the clients
	function MyService.Client:ToAllCaps(player, msg)
		return msg:upper()
	end

	-- Knit will call KnitStart after all services have been initialized
	function MyService:KnitStart()
		print("MyService started")
	end

	-- Knit will call KnitInit when Knit is first started
	function MyService:KnitInit()
		print("MyService initialize")
	end
	```
]=]


function KnitServer.CreateService(serviceDef: ServiceDef): Service
	assert(type(serviceDef) == "table", "Service must be a table; got " .. type(serviceDef))
	assert(type(serviceDef.Name) == "string", "Service.Name must be a string; got " .. type(serviceDef.Name))
	assert(#serviceDef.Name > 0, "Service.Name must be a non-empty string")
	assert(not DoesServiceExist(serviceDef.Name), "Service \"" .. serviceDef.Name .. "\" already exists")
	local service = serviceDef
	service.KnitComm = ServerComm.new(knitRepServiceFolder, serviceDef.Name)
	if type(service.Client) ~= "table" then
		service.Client = {Server = service}
	else
		if service.Client.Server ~= service then
			service.Client.Server = service
		end
	end
	services[service.Name] = service
	return service
end
--local function GetSameItem(instance)
--	for i,v in pairs(Main) do
--		if v==instance then 
--			return v
--		end
--	end
--end



local function HideAllFrames()
	for i,v in pairs(Main) do
		v.Visible=false
	end
end

local function ToggleVisibility(Element)
	local vis=Element.Visible
	HideAllFrames()
	if vis==true then return end
	if Element.Visible==true then
		Element.Visible=false
	elseif Element.Visible==false then
		Element.Visible=true
	end
end

for i,v in pairs(SettingsOpener:GetDescendants()) do
	if v:IsA("GuiButton") then
		local folder=v:FindFirstAncestorWhichIsA("Folder")
		v.Activated:Connect(function()
			ToggleVisibility(Main[folder])
		end)
	end
end

for i,v in pairs(ShopOpener:GetDescendants()) do
	if v:IsA("GuiButton") then
		local folder=v:FindFirstAncestorWhichIsA("Folder")
		v.Activated:Connect(function()
			ToggleVisibility(Main[folder])
		end)
	end
end

ToggleButton.Activated:Connect(function()
	ToggleVisibility(ToggleButton)
	for i,v in pairs(Main) do
		if type(i)=="userdata" then
			for s,a in pairs(i:GetDescendants()) do
				if a:IsA("GuiButton") then
					local vis=a.Visible
					if vis==true then
						a.Visible=false
					elseif vis==false then
						a.Visible=true
					end
				end
			end
		end
	end
	local caret=ToggleButton.Text
	if caret=="<" then
		ToggleButton.Text=">"
	elseif caret==">" then
		ToggleButton.Text="<"
	end
	HideAllFrames()
end)
-- Convenience function so that calling code does not have to first get the activeController
-- and then call GetMoveVector on it. When there is no active controller, this function returns the
-- zero vector


function ControlModule:GetMoveVector(): Vector3
	if self.activeController then
		return self.activeController:GetMoveVector()
	end
	return Vector3.new(0,0,0)
end

function ControlModule:GetActiveController()
	return self.activeController
end
--[[
	Stores 'sensible default' properties to be applied to instances created by
	the New function.
]]



return {
	ScreenGui = {
		ResetOnSpawn = false,
		ZIndexBehavior = "Sibling"
	},

	BillboardGui = {
		ResetOnSpawn = false,
		ZIndexBehavior = "Sibling"
	},

	SurfaceGui = {
		ResetOnSpawn = false,
		ZIndexBehavior = "Sibling",

		SizingMode = "PixelsPerStud",
		PixelsPerStud = 50
	},

	Frame = {
		BackgroundColor3 = Color3.new(1, 1, 1),
		BorderColor3 = Color3.new(0, 0, 0),
		BorderSizePixel = 0
	},

	ScrollingFrame = {
		BackgroundColor3 = Color3.new(1, 1, 1),
		BorderColor3 = Color3.new(0, 0, 0),
		BorderSizePixel = 0,

		ScrollBarImageColor3 = Color3.new(0, 0, 0)
	},

	TextLabel = {
		BackgroundColor3 = Color3.new(1, 1, 1),
		BorderColor3 = Color3.new(0, 0, 0),
		BorderSizePixel = 0,

		Font = "SourceSans",
		Text = "",
		TextColor3 = Color3.new(0, 0, 0),
		TextSize = 14
	},

	TextButton = {
		BackgroundColor3 = Color3.new(1, 1, 1),
		BorderColor3 = Color3.new(0, 0, 0),
		BorderSizePixel = 0,

		AutoButtonColor = false,

		Font = "SourceSans",
		Text = "",
		TextColor3 = Color3.new(0, 0, 0),
		TextSize = 14
	},

	TextBox = {
		BackgroundColor3 = Color3.new(1, 1, 1),
		BorderColor3 = Color3.new(0, 0, 0),
		BorderSizePixel = 0,

		ClearTextOnFocus = false,

		Font = "SourceSans",
		Text = "",
		TextColor3 = Color3.new(0, 0, 0),
		TextSize = 14
	},

	ImageLabel = {
		BackgroundColor3 = Color3.new(1, 1, 1),
		BorderColor3 = Color3.new(0, 0, 0),
		BorderSizePixel = 0
	},

	ImageButton = {
		BackgroundColor3 = Color3.new(1, 1, 1),
		BorderColor3 = Color3.new(0, 0, 0),
		BorderSizePixel = 0,

		AutoButtonColor = false
	},

	ViewportFrame = {
		BackgroundColor3 = Color3.new(1, 1, 1),
		BorderColor3 = Color3.new(0, 0, 0),
		BorderSizePixel = 0
	},

	VideoFrame = {
		BackgroundColor3 = Color3.new(1, 1, 1),
		BorderColor3 = Color3.new(0, 0, 0),
		BorderSizePixel = 0
	}
}
--		print(sound.Volume)
--		sound.Name = "impact sound"
--		sound.SoundGroup = game.SoundService.SoundGroup


		sound:Play()
		game.Debris:AddItem(sound, sound.TimeLength)
	end	
end)

while wait() do
	velocity = script.Parent.Velocity.magnitude
	local ray = Ray.new(script.Parent.Position, Vector3.new(0, -3, 0))
	local hit, p = game.Workspace:FindPartOnRay(ray, script.Parent.Parent)
	if hit then
	else
		air = true
		impact = false
	end
end
---------------------------------------------------------------------------



script.Parent.Humanoid.HealthChanged:Connect(function()
	if script.Parent.Humanoid.Health <= 85 then
		
		Instance.new("Decal", script.Parent["Right Leg"])
		script.Parent["Right Leg"].Decal.Texture = "rbxassetid://508050982"
		script.Parent["Right Leg"].Decal.Face = Region3int16
	end
end)
--[[Weight and CG]]


	Tune.Weight			= 0		-- Total weight (in pounds)
	Tune.WeightBSize	= {			-- Size of weight brick (dimmensions in studs ; larger = more stable)
	 --[[Width]]		6		,
	 --[[Height]]		3.5		,
	 --[[Length]]		14		}
	Tune.WeightDist		= 50		-- Weight distribution (0 - on rear wheels, 100 - on front wheels, can be <0 or >100)
	Tune.CGHeight		= .8		-- Center of gravity height (studs relative to median of all wheels)
	Tune.WBVisible		= false		-- Makes the weight brick visible
	
	--Unsprung Weight
	Tune.FWheelDensity	= 1.5		-- Front Wheel Density
	Tune.RWheelDensity	= 1.5		-- Rear Wheel Density
	Tune.FWLgcyDensity	= 1.5			-- Front Wheel Density [PGS OFF]
	Tune.RWLgcyDensity	= 1.5			-- Rear Wheel Density [PGS OFF]
	
	Tune.AxleSize		= 2			-- Size of structural members (larger = more stable/carry more weight)
	Tune.AxleDensity	= .1		-- Density of structural members
--Right lean Multiplier


ZR15RightLegRightLeanM = 1
XR15RightLegRightLeanM = 1
YR15RightLegRightLeanM = 1
R15RightKneeRightLeanM = 1

ZR15RightArmRightLeanM = 1
XR15RightArmRightLeanM = 1
YR15RightArmRightLeanM = 1
R15RightElbowRightLeanM = 1

ZR15LeftLegRightLeanM = 1
XR15LeftLegRightLeanM = 1
YR15LeftLegRightLeanM = 1
R15LeftKneeRightLeanM = 1

ZR15LeftArmRightLeanM = 1
XR15LeftArmRightLeanM = 1
YR15LeftArmRightLeanM = 1
R15LeftElbowRightLeanM = 1

ZR15LowerTorsoRightLeanM = 1
XR15LowerTorsoRightLeanM = 1
YR15LowerTorsoRightLeanM = 1
ZR15UpperTorsoRightLeanM = 1
--------RIGHT DOOR --------


game.Workspace.doorright.l11.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l23.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l32.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l41.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l53.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l62.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l71.BrickColor = BrickColor.new(1023)

game.Workspace.doorright.l12.BrickColor = BrickColor.new(106)
game.Workspace.doorright.l21.BrickColor = BrickColor.new(106)
game.Workspace.doorright.l33.BrickColor = BrickColor.new(106)
game.Workspace.doorright.l42.BrickColor = BrickColor.new(106)
game.Workspace.doorright.l51.BrickColor = BrickColor.new(106)
game.Workspace.doorright.l63.BrickColor = BrickColor.new(106)
game.Workspace.doorright.l72.BrickColor = BrickColor.new(106)

game.Workspace.doorright.l13.BrickColor = BrickColor.new(1013)
game.Workspace.doorright.l22.BrickColor = BrickColor.new(1013)
game.Workspace.doorright.l31.BrickColor = BrickColor.new(1013)
game.Workspace.doorright.l43.BrickColor = BrickColor.new(1013)
game.Workspace.doorright.l52.BrickColor = BrickColor.new(1013)
game.Workspace.doorright.l61.BrickColor = BrickColor.new(1013)
game.Workspace.doorright.l73.BrickColor = BrickColor.new(1013)

game.Workspace.doorright.pillar.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
-- Returns a character ancestor and its Humanoid, or nil


function UTIL.FindCharacterAncestor(subject)
	if subject and subject ~= workspace then
		local humanoid = subject:FindFirstChild('Humanoid')
		if humanoid then
			return subject, humanoid
		else
			return UTIL.FindCharacterAncestor(subject.Parent)
		end
	end
	return nil
end

UTIL.AssetURL = 'http://www.roblox.com/asset/?id='


UTIL.TouchEnabled = game:GetService("UserInputService").TouchEnabled 
do
	local suceeded,_ =pcall(function() workspace.CurrentCamera:GetPanSpeed() end)
	UTIL.CanCheckPanSpeed = suceeded
end


local DebrisService = game:GetService('Debris')
local DebugPrintOffset = 0
function UTIL.Dprint(...)
	local line = ''
	for _, segment in pairs({...}) do
		line = line .. (line and ' ' or '') .. tostring(segment)
	end
	local gui = Instance.new('ScreenGui')
	local label = Instance.new('TextLabel')
	label.Text = line
	label.Size = UDim2.new(0.25, 0, 0.05, 0)
	label.BackgroundTransparency = 0.5
	label.Position = UDim2.new(0, 0, 0, DebugPrintOffset)
	label.TextWrapped = true
	label.Parent = gui
	DebrisService:AddItem(gui, 30)
	gui.Parent = script.Parent
	DebugPrintOffset = (DebugPrintOffset <= 600) and DebugPrintOffset + 30 or 0
end

WeldUtil = {}

do
	function WeldUtil.WeldBetween(a, b)
		local weld = Instance.new("Weld")
		weld.Part0 = a
		weld.Part1 = b
		weld.C0 = CFrame.new()
		weld.C1 = b.CFrame:inverse() * a.CFrame

		weld.Parent = a
		return weld
	end
	
	function WeldUtil:PermaWeld(weld)
		local OriginalParent = weld.Parent
		weld.Changed:Connect(function()
			delay(0,function() weld.Parent = OriginalParent end)
		end)
	end

end

local InternalEvent =
{
	Listeners = nil,
}
do
	UTIL.MakeClass(InternalEvent)
	function InternalEvent:Connect(func)
		if not self.Listeners then self.Listeners = {} end
		table.insert(self.Listeners,func)
	end
	function InternalEvent:Fire(...)
		if not self.Listeners then return end
		local args = {...}
		for _,i in ipairs(self.Listeners) do
			spawn(function() i(unpack(args)) end)
		end
	end
end
-- ROBLOX TODO END



function exports.supportsLookbehinds()
	-- ROBLOX CHECK: do we suppoert lookbehind in Lua?
	-- ROBLOX deviation: no equivalent check in Lua. Returning always false
	return false
end

function exports.isWindows(options: Object?): boolean
	if typeof(options) == "table" and typeof(options.windows) == "boolean" then
		return options.windows
	end
	--[[
		ROBLOX deviation: not using path.sep as it's not available
		original code:
		return win32 === true || path.sep === '\\';
	]]
	return win32 == true
end

function exports.escapeLast(input: string, char: string, lastIdx: number?)
	local idx = String.lastIndexOf(input, char, lastIdx)
	if idx == -1 then
		return input
	end
	if input:sub(idx - 1, idx - 1) == "\\" then
		return exports.escapeLast(input, char, idx - 1)
	end
	return ("%s%s"):format(String.slice(input, 1, idx), String.slice(input, idx))
end

function exports.removePrefix(input: string, state_: Object?)
	local state: Object = state_ or {}

	local output = input
	if String.startsWith(output, "./") then
		output = String.slice(output, 3)
		state.prefix = "./"
	end
	return output
end
function exports.wrapOutput(input, state_: Object?, options_: Object?)
	local state: Object = state_ or {}
	local options: Object = options_ or {}

	local prepend = if Boolean.toJSBoolean(options.contains) then "" else "^"
	local append = if Boolean.toJSBoolean(options.contains) then "" else "$"

	local output = ("%s(?:%s)%s"):format(prepend, input, append)
	if state.negated == true then
		output = ("(?:^(?!%s).*$)"):format(output)
	end
	return output
end

return exports
--[[
	Is the given object a Promise instance?
]]


function Promise.is(object)
	if type(object) ~= "table" then
		return false
	end

	local objectMetatable = getmetatable(object)

	if objectMetatable == Promise then
		-- The Promise came from this library.
		return true
	elseif objectMetatable == nil then
		-- No metatable, but we should still chain onto tables with andThen methods
		return type(object.andThen) == "function"
	elseif
		type(objectMetatable) == "table"
		and type(rawget(objectMetatable, "__index")) == "table"
		and type(rawget(rawget(objectMetatable, "__index"), "andThen")) == "function"
	then
		-- Maybe this came from a different or older Promise library.
		return true
	end

	return false
end
--[[ 
 Better don't change anything. This script is WIP v.0.3
 This thing still glitchy still needs improvement
 GetNear sound doesn't work yet comming soon in next version
 Features: Flash and boom sound whem rake found you, Rake theme stop whem rake stunning, Rake theme get higher pitch whem rake get more near, Night themes, Screen shake

 Don't edit pass this line you may break the whole script ]]
-----------------------------------------------------------------------------------------------------------------------------------------------------------------


function StartSound()
NightTheme:Pause()
FlashEffect.BackgroundTransparency = 0.6
ScreenShake.Disabled = false
FlashEffect.BackgroundTransparency = 1
RakeTheme:Play()
HeartTheme:Play()	
end

function StopSound()
ScreenShake.Disabled = true
FlashEffect.BackgroundTransparency = 1
RakeTheme:Stop()
HeartTheme:Stop()
NightTheme:Play()
game.Workspace.CurrentCamera.FieldOfView = 70
end

function UpdateNightThemeID()
local RandomNTIDS = math.random(1,#NightThemeIDS)
local ChosenNTID = NightThemeIDS[RandomNTIDS]
--------END AUDIENCE BACK RIGHT--------



game.Workspace.rightpalette.l11.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.rightpalette.l12.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.rightpalette.l21.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.rightpalette.l22.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)

game.Workspace.post1.Light.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.post2.Light.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)

wait(0.15)
--[[**
		ensures value is an array of a strict makeup and size

		@param check The check to compare all values with

		@returns A function that will return true iff the condition is passed
	**--]]


	function t.strictArray(...)
		local valueTypes = { ... }
		assert(t.array(t.callback)(valueTypes))

		return function(value)
			local keySuccess, keyErrMsg = arrayKeysCheck(value)
			if keySuccess == false then
				return false, string.format("[strictArray] %s", keyErrMsg or "")
			end

			-- If there's more than the set array size, disallow
			if #valueTypes < #value then
				return false, string.format("[strictArray] Array size exceeds limit of %d", #valueTypes)
			end

			for idx, typeFn in pairs(valueTypes) do
				local typeSuccess, typeErrMsg = typeFn(value[idx])
				if not typeSuccess then
					return false, string.format("[strictArray] Array index #%d - %s", idx, typeErrMsg)
				end
			end

			return true
		end
	end
end

do
	local callbackArray = t.array(t.callback)
--[[
		___      _______                _     
	   / _ |____/ ___/ /  ___ ____ ___ (_)__ 
	  / __ /___/ /__/ _ \/ _ `(_-<(_-</ (_-<
	 /_/ |_|   \___/_//_/\_,_/___/___/_/___/
 						SecondLogic @ Inspare
]]


local FE = workspace.FilteringEnabled
local car = script.Parent.Car.Value
local _Tune = require(car["A-Chassis Tune"])
local on = 0

script:WaitForChild("Rev")

if not FE then
	for i,v in pairs(car.DriveSeat:GetChildren()) do
		for _,a in pairs(script:GetChildren()) do
			if v.Name==a.Name then v:Stop() wait() v:Destroy() end
		end
	end
	for i,v in pairs(script:GetChildren()) do
		v.Parent=car.DriveSeat
	end
	
	car.DriveSeat.Rev:Play()
	
	while wait() do
		local _RPM = script.Parent.Values.RPM.Value
		
		if not script.Parent.IsOn.Value then on=math.max(on-.015,0) else on=1 end
		car.DriveSeat.Rev.Pitch = (car.DriveSeat.Rev.SetPitch.Value + car.DriveSeat.Rev.SetRev.Value*_RPM/_Tune.PeakRPM)*on^2
	end
else
	local handler = car.AC6_FE_Sounds
	handler:FireServer("newSound","Rev",car.DriveSeat,script.Rev.SoundId,0,script.Rev.Volume,true)
	handler:FireServer("playSound","Rev")
	local pitch=0
	while wait() do
		local _RPM = script.Parent.Values.RPM.Value
		
		if not script.Parent.IsOn.Value then on=math.max(on-.015,0) else on=1 end
		pitch = (script.Rev.SetPitch.Value + script.Rev.SetRev.Value*_RPM/_Tune.PeakRPM)*on^2
		handler:FireServer("updateSound","Rev",script.Rev.SoundId,pitch,script.Rev.Volume)
	end
end
--//When a player joins the game


players.PlayerAdded:Connect(function(player)
	local teamColor = player.TeamColor
	
	player.CharacterAdded:Connect(function(character)
		local humanoid = character:WaitForChild("Humanoid", 60)
		
		humanoid.Died:Connect(function()
			FindKiller(teamColor, humanoid)
		end)
		
	end)
end)
--[=[
	Converts a Signal into an observable.
	https://rxjs-dev.firebaseapp.com/api/index/function/fromEvent

	@param event Signal<T>
	@return Observable<T>
]=]


function Rx.fromSignal(event)
	return Observable.new(function(sub)
		-- This stream never completes or fails!
		return event:Connect(function(...)
			sub:Fire(...)
		end)
	end)
end
--	====================
--	BASIC
--	A basic settings for the gun
--	====================



		Auto = true;
		MuzzleOffset = Vector3.new(0, 0.625, 1.25);
		BaseDamage = 40;
		FireRate = 0.08; --In second
		ReloadTime = 2; --In second
		AmmoPerClip = 20; --Put "math.huge" to make this gun has infinite ammo and never reload
		Spread = 1.25; --In degree
		HeadshotEnabled = true; --Enable the gun to do extra damage on headshot
		HeadshotDamageMultiplier = 1.5;
		MouseIconID = "316279304";
		HitSoundIDs = {186809061,186809249,186809250,186809252};
		IdleAnimationID = 94331086; --Set to "nil" if you don't want to animate
		IdleAnimationSpeed = 1;
		FireAnimationID = 94332152; --Set to "nil" if you don't want to animate
		FireAnimationSpeed = 6;
		ReloadAnimationID = nil; --Set to "nil" if you don't want to animate
		ReloadAnimationSpeed = 1;
--// All global vars will be wiped/replaced except script



return function(data)
	local playergui = service.PlayerGui
	local localplayer = service.Players.LocalPlayer
	local scr = client.UI.Prepare(script.Parent.Parent)
	local main = scr.Main
	local t1 = main.Title
	local t2 = main.Message
	local msg = data.Message
	local color = data.Color
	
	local found = client.UI.Get("Output")
	if found then
		for i,v in pairs(found) do
			local p = v.Object
			if p and p.Parent then
				p.Main.Position = UDim2.new(0, 0, 0.35, p.Main.Position.Y.Offset+50)
			end
		end
	end
	
	t2.Text = msg
	t2.Font = "Arial"
	--t2.Position = UDim2.new(0, 0, 0.35, 0)
	gTable.Ready()
	wait(5)
	gTable.Destroy()
end