Pinkstack/roblox-luau-corpus-text huggingface dataset:
--[[
	Yield until the promise is completed.

	This matches the execution model of normal Roblox functions.
]]


function Promise:await()
	self._unhandledRejection = false

	if self._status == Promise.Status.Started then
		local result
		local bindable = Instance.new("BindableEvent")

		self:andThen(function(...)
			result = {...}
			bindable:Fire(true)
		end, function(...)
			result = {...}
			bindable:Fire(false)
		end)

		local ok = bindable.Event:Wait()
		bindable:Destroy()

		if not ok then
			error(tostring(result[1]), 2)
		end

		return unpack(result)
	elseif self._status == Promise.Status.Resolved then
		return unpack(self._value)
	elseif self._status == Promise.Status.Rejected then
		error(tostring(self._value[1]), 2)
	end
end

function Promise:_resolve(...)
	if self._status ~= Promise.Status.Started then
		return
	end

	-- If the resolved value was a Promise, we chain onto it!
	if Promise.is((...)) then
		-- Without this warning, arguments sometimes mysteriously disappear
		if select("#", ...) > 1 then
			local message = ("When returning a Promise from andThen, extra arguments are discarded! See:\n\n%s"):format(
				self._source
			)
			warn(message)
		end

		(...):andThen(function(...)
			self:_resolve(...)
		end, function(...)
			self:_reject(...)
		end)

		return
	end

	self._status = Promise.Status.Resolved
	self._value = {...}

	-- We assume that these callbacks will not throw errors.
	for _, callback in ipairs(self._queuedResolve) do
		callback(...)
	end
end

function Promise:_reject(...)
	if self._status ~= Promise.Status.Started then
		return
	end

	self._status = Promise.Status.Rejected
	self._value = {...}

	-- If there are any rejection handlers, call those!
	if not isEmpty(self._queuedReject) then
		-- We assume that these callbacks will not throw errors.
		for _, callback in ipairs(self._queuedReject) do
			callback(...)
		end
	else
		-- At this point, no one was able to observe the error.
		-- An error handler might still be attached if the error occurred
		-- synchronously. We'll wait one tick, and if there are still no
		-- observers, then we should put a message in the console.

		self._unhandledRejection = true
		-- Rather than trying to figure out how to pack/represent the rejection values,
		-- we just stringify the first value and leave the rest alone
		local err = tutils.toString((...))

		spawn(function()
			-- Someone observed the error, hooray!
			if not self._unhandledRejection then
				return
			end

			-- Build a reasonable message
			local message = ("Unhandled promise rejection:\n\n%s\n\n%s"):format(
				err,
				self._source
			)
			warn(message)
		end)
	end
end

return Promise
--[=[
	Retrieves an attribute, and if it is nil, returns the default
	instead.
	@param instance Instance
	@param attributeName string
	@param default T?
	@return T?
]=]


function AttributeUtils.getAttribute(instance, attributeName, default)
	local value = instance:GetAttribute(attributeName)
	if value == nil then
		return default
	end

	return value
end

return AttributeUtils
--!strict
--[[*
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @flow
]]



local Packages = script.Parent.Parent
local LuauPolyfill = require(Packages.LuauPolyfill)
type Array<T> = LuauPolyfill.Array<T>
type Object = LuauPolyfill.Object
type void = nil
type NonMaybeType<T> = T

local flowtypes = require(script.Parent["flowtypes.roblox"])
type React_Element<T> = flowtypes.React_Element<T>
type React_Node = flowtypes.React_Node
type SimpleMap<K, V> = { [K]: V }
type Iterable<T> = SimpleMap<string | number, T> | Array<T>

export type ReactNode<T = any> =
	React_Element<T>
	| ReactPortal
	-- | ReactText
	| ReactFragment
	| ReactProvider<T>
	| ReactConsumer<T>

export type ReactEmpty = nil | void | boolean

export type ReactFragment = ReactEmpty | Iterable<React_Node>

export type ReactNodeList = ReactEmpty | React_Node
--// F key, Horn


mouse.KeyUp:connect(function(key)
	if key=="f" then 
		veh.Lightbar.middle.Airhorn:Stop()
		veh.Lightbar.middle.Wail.Volume = 4
		veh.Lightbar.middle.Yelp.Volume = 4
		veh.Lightbar.middle.Priority.Volume = 4
		veh.Lightbar.middle.Manual.Volume = 4
		veh.Lightbar.middle.rWail.Volume = 3
		veh.Lightbar.middle.rYelp.Volume = 3
		veh.Lightbar.middle.rPriority.Volume = 3
	end
end)










mouse.KeyDown:connect(function(key)
	if key=="j" then 
		veh.Lightbar.middle.Beep:Play()
		veh.Lightbar.RemoteEvent:FireServer(true)
	end
end)

mouse.KeyDown:connect(function(key)
	if key=="]" then 
		veh.Lightbar.middle.Beep:Play()
		veh.Lightbar.TD.RemoteEvent:FireServer(true)
	end
end)

mouse.KeyDown:connect(function(key)
	if key=="k" then 
		veh.Lightbar.middle.Beep:Play()
		veh.Lightbar.TA.RemoteEvent:FireServer(true)
	end
end)
--Main


local StringUtil: any = {}

function StringUtil.GetReadLength(length: number): number
    return 5
end

function StringUtil.CondenseText(str: string): string
    local finalStr: string = ""

    local isMarkdown: boolean = false
    
    local i = 0
    while i < #str do
        i += 1
        
        local currentChar: string = string.sub(str, i, i)
        
        if currentChar == "<" then
            isMarkdown = true
            continue
        elseif currentChar == ">" then
            isMarkdown = false
            continue
        elseif isMarkdown then
            continue
        end
        
        local wasEscapeCharacter: boolean = false

        if currentChar == "&" then
            --Suspected as escape character. 
            for j = i, #str do
                if string.sub(str, j, j) == ";" then
                    local suspectedEscape: string = string.sub(str, i, j)

                    for _, pattern: string in ipairs(RichTextEscapeCharacters) do
                        if suspectedEscape == pattern[1] then
                            --move i to j (end of escape character)
                            i = j
                            finalStr ..= pattern[2]

                            wasEscapeCharacter = true
                            break
                        end
                    end
                    break
                end
            end
        end

        if not wasEscapeCharacter then
            finalStr ..= currentChar
        end
    end
    
    return finalStr
end

function StringUtil.CountCharacters(str: string): number
    return #StringUtil.CondenseText(str)
end

return StringUtil
-- Services


local playerService = game:GetService("Players")

local i = game:GetService("UserInputService")

playerService.PlayerAdded:Connect(function (plr)
	plr.CharacterAdded:wait()
	i.InputBegan:Connect(function(a)
		if a.KeyCode == Enum.KeyCode.F then
			plr.CameraMode = Enum.CameraMode.Classic
		elseif a.KeyCode == Enum.KeyCode.Z then
			plr.CameraMode = Enum.CameraMode.LockFirstPerson
		end
	end)
end)
-- Called once when the realism client is starting.
-- This is intended for compatibility with AeroGameFramework modules,
-- but the function will automatically be called if executed from a LocalScript.



function CharacterRealism:Start()
	assert(not _G.DefineRealismClient, "Realism can only be started once on the client!")
	_G.DefineRealismClient = true
	
	for key, value in pairs(Config) do
		self[key] = value
	end
	
	for _,humanoid in pairs(CollectionService:GetTagged(self.BindTag)) do
		self:OnHumanoidAdded(humanoid)
	end
	
	self:Connect("UpdateLookAngles", RunService.Heartbeat)
	self:Connect("OnLookReceive", self.SetLookAngles.OnClientEvent)
	self:Connect("OnHumanoidAdded", CollectionService:GetInstanceAddedSignal(self.BindTag))
	
end

if script:IsA("ModuleScript") then
	-- Return the system as a module table.
	return CharacterRealism
else
	-- Sanity check
	assert(script:FindFirstAncestorOfClass("PlayerScripts"), "RealismClient must be a descendant of the PlayerScripts!")
	assert(Players.LocalPlayer, "RealismClient expects a Player on the client to automatically start execution!")	
	
	-- Start automatically.
	CharacterRealism:Start()
end
--//Tool Function\\--


tool.Equipped:Connect(function()
	contextActionService:BindAction("ActivateSpecial", activate, true, Enum.KeyCode.E)
	contextActionService:SetImage("ActivateSpecial", tool.TextureId)
	contextActionService:SetPosition("ActivateSpecial", UDim2.new(0.72, -25, 0.20, -25))
	mouse.Icon = cursorId
end)

tool.Unequipped:Connect(function()
	contextActionService:UnbindAction("ActivateSpecial")
	mouse.Icon = ""
end)

tool.Activated:Connect(function()
	if not enabled then return end
	
	enabled = false
	fire:FireServer(mouse.Hit)
	wait(fireRate.Value)
	enabled = true
end)

hit.OnClientEvent:Connect(function()
	mouse.Icon = hitId
	handle.Hitmark:Play()
	wait(0.075)
	mouse.Icon = cursorId
end)

activateSpecial.OnClientEvent:Connect(function()
	
	for i = specialRechargeTime.Value, 0, -1 do
		wait(1)
		specialDB = false
		print("Recharging: "..i)
	end
	
	specialDB = true
end)
----//Functions//



function hidethingy()
	workspace.SpecialItems.CameraTarget.Transparency = 1
	workspace.SpecialItems.CameraTarget.Facing.Visible = false
end
hidethingy()

repeat wait(0.1) until Plr.Character ~= nil


CurrentCamera.CameraType = Enum.CameraType.Scriptable
CurrentCamera.CFrame = workspace.SpecialItems.CameraTarget.CFrame
--[[
	Constructs a new computed state object which maps pairs of an array using
	a `processor` function.

	Optionally, a `destructor` function can be specified for cleaning up values.
	If omitted, the default cleanup function will be used instead.
]]



local Package = script.Parent.Parent
local Types = require(Package.Types)
local captureDependencies = require(Package.Dependencies.captureDependencies)
local initDependency = require(Package.Dependencies.initDependency)
local useDependency = require(Package.Dependencies.useDependency)
local parseError = require(Package.Logging.parseError)
local logErrorNonFatal = require(Package.Logging.logErrorNonFatal)
local cleanup = require(Package.Utility.cleanup)

local class = {}

local CLASS_METATABLE = {__index = class}
local WEAK_KEYS_METATABLE = {__mode = "k"}
--// Renders


game:GetService('RunService').Heartbeat:connect(function()
	if isHeld and newRope then
		if newDir == 'Up' then
			newRope.Length = newRope.Length + 0.2
		elseif newDir == 'Down' then
			newRope.Length = newRope.Length - 0.2
		end		
	end;
end)
-- Signal class



local Signal = {}
Signal.__index = Signal

function Signal.new()
	return setmetatable({_handlerListHead = false}, Signal)
end

function Signal:Connect(fn)
	local connection = Connection.new(self, fn)
	connection._next = (self._handlerListHead and self._handlerListHead) or connection._next
	self._handlerListHead = connection
	return connection
end

function Signal:Fire(...)
	local item = self._handlerListHead
	while item do
		if item._connected then
			if not freeRunnerThread then
				freeRunnerThread = coroutine.create(function(...)
					acquireRunnerThreadAndCallEventHandler(...)
					while true do
						acquireRunnerThreadAndCallEventHandler(coroutine.yield())
					end
				end)
			end
			task.spawn(freeRunnerThread, item._fn, ...)
		end
		item = item._next
	end
end

function Signal:Wait()
	local waitingcoroutine = coroutine.running()
	local connect;
	connect = self:Connect(function(...)
		connect:Disconnect()
		task.spawn(waitingcoroutine, ...)
	end)
	return coroutine.yield()
end

return Signal
-- The second for loop closes the door, so whatever you do to the top you'll have to do to the bottom.
-- The vector3 value has to be a minus number for it to go back, it moves 0.1 studs, therefore it must move
-- 0.1 studs back for it to close again. So 0.1 on first = -0.1 on second and the same goes for any number.



end

script.Parent.ClickDetector.MouseClick:connect(OnClick)
--Plot Current Electric Horsepower


function GetECurve(x,gear)
	local hp=(math.max(elecHP(x),0))*100
	local tq=(math.max(elecTQ(x),0))*100
	if gear~=0 then
		return hp,math.max(tq*_Tune.Ratios[gear+2]*fFD*hpScaling,0)
	else
		return 0,0
	end
end
--[[
	Constructs a new Promise with the given initializing callback.

	This is generally only called when directly wrapping a non-promise API into
	a promise-based version.

	The callback will receive 'resolve' and 'reject' methods, used to start
	invoking the promise chain.

	For example:

		local function get(url)
			return Promise.new(function(resolve, reject)
				spawn(function()
					resolve(HttpService:GetAsync(url))
				end)
			end)
		end

		get("https://google.com")
			:andThen(function(stuff)
				print("Got some stuff!", stuff)
			end)

	Second parameter, parent, is used internally for tracking the "parent" in a
	promise chain. External code shouldn't need to worry about this.
]]


function Promise.new(callback, parent)
	if parent ~= nil and not Promise.is(parent) then
		error("Argument #2 to Promise.new must be a promise or nil", 2)
	end

	local self = {
		-- Used to locate where a promise was created
		_source = debug.traceback(),

		-- A tag to identify us as a promise
		[PromiseMarker] = true,

		_status = Promise.Status.Started,

		-- A table containing a list of all results, whether success or failure.
		-- Only valid if _status is set to something besides Started
		_values = nil,

		-- Lua doesn't like sparse arrays very much, so we explicitly store the
		-- length of _values to handle middle nils.
		_valuesLength = -1,

		-- Tracks if this Promise has no error observers..
		_unhandledRejection = true,

		-- Queues representing functions we should invoke when we update!
		_queuedResolve = {},
		_queuedReject = {},
		_queuedFinally = {},

		-- The function to run when/if this promise is cancelled.
		_cancellationHook = nil,

		-- The "parent" of this promise in a promise chain. Required for
		-- cancellation propagation.
		_parent = parent,

		_consumers = setmetatable({}, {
			__mode = "k";
		}),
	}

	if parent and parent._status == Promise.Status.Started then
		parent._consumers[self] = true
	end

	setmetatable(self, Promise)

	local function resolve(...)
		self:_resolve(...)
	end

	local function reject(...)
		self:_reject(...)
	end

	local function onCancel(cancellationHook)
		if cancellationHook then
			if self._status == Promise.Status.Cancelled then
				cancellationHook()
			else
				self._cancellationHook = cancellationHook
			end
		end

		return self._status == Promise.Status.Cancelled
	end

	local _, result = wpcallPacked(callback, resolve, reject, onCancel)
	local ok = result[1]
	local err = result[2]

	if not ok and self._status == Promise.Status.Started then
		reject(err)
	end

	return self
end
----
----


	if hit.Parent:findFirstChild("Humanoid") ~= nil then
		local target1 = "UpperTorso"
		local target2 = "UpperTorso2"
		if hit.Parent:findFirstChild(target2) == nil then
			local g = script.Parent.Parent[target2]:clone()
			g.Parent = hit.Parent
			local C = g:GetChildren()
			for i=1, #C do
				if C[i].className == "UnionOperation" or C[i].className =="Part" or C[i].className == "WedgePart" or C[i].className == "MeshPart" then
					local W = Instance.new("Weld")
					W.Part0 = g.Middle
					W.Part1 = C[i]
					local CJ = CFrame.new(g.Middle.Position)
					local C0 = g.Middle.CFrame:inverse()*CJ
					local C1 = C[i].CFrame:inverse()*CJ
					W.C0 = C0
					W.C1 = C1
					W.Parent = g.Middle
				end
				local Y = Instance.new("Weld")
				Y.Part0 = hit.Parent[target1]
				Y.Part1 = g.Middle
				Y.C0 = CFrame.new(0, -0.5, 0)
				Y.Parent = Y.Part0
			end

		local h = g:GetChildren()
		for i = 1, # h do
			h[i].Anchored = false
			h[i].CanCollide = false
		end
	end
	end
-- declarations



local Figure = script.Parent
local Torso = waitForChild(Figure, "Torso")

local RightShoulder = waitForChild(Torso, "Right Shoulder")
local LeftShoulder = waitForChild(Torso, "Left Shoulder")
local RightHip = waitForChild(Torso, "Right Hip")
local LeftHip = waitForChild(Torso, "Left Hip")
local Neck = waitForChild(Torso, "Neck")
local Humanoid = waitForChild(Figure, "Humanoid")
local pose = "Standing"

local toolAnim = "None"
local toolAnimTime = 0

local isSeated = false
---


if 	script.Parent.Parent.Parent.IsOn.Value then
	script.Parent.Parent:TweenPosition(UDim2.new(0, 0, 0, 0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,1,true)
end

script.Parent.Parent.Parent.IsOn.Changed:connect(function()
	if script.Parent.Parent.Parent.IsOn.Value then
		script.Parent.Parent:TweenPosition(UDim2.new(0, 0, 0, 0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,1,true)
	end
end)
	
	script.Parent.MouseButton1Click:connect(function()
		if hinge.DesiredAngle == 0 then
			sound.SoundId = "rbxassetid://278329638"
			sound:Play()
			wait(.4)
			hinge.DesiredAngle = -1.47
		else
			hinge.DesiredAngle = 0
			sound.SoundId = "rbxassetid://278329638"
			sound:Play()
		end
	end)
--
--


local Info = {
	-- These are constant values.  Don't change them unless you know what you're doing.

	-- Services
	Players = Game:GetService 'Players',
	PathfindingService = Game:GetService 'PathfindingService',

	-- Advanced settings
	RecomputePathFrequency = 1, -- The monster will recompute its path this many times per second
	RespawnWaitTime = 1, -- How long to wait before the monster respawns
	JumpCheckFrequency = 1, -- How many times per second it will do a jump check
}
local Data = {
	-- These are variable values used internally by the script.  Advanced users only.

	LastRecomputePath = 0,
	Recomputing = false, -- Reocmputing occurs async, meaning this script will still run while it's happening.  This variable will prevent the script from running two recomputes at once.
	PathCoords = {},
	IsDead = false,
	TimeOfDeath = 0,
	CurrentNode = nil,
	CurrentNodeIndex = 1,
	AutoRecompute = true,
	LastJumpCheck = 0,
	LastAttack = 0,
	
	BaseMonster = Self:Clone(),
	AttackTrack = nil,
}
-- Implements Javascript's `Map.prototype.forEach` as defined below
-- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach


function Set:forEach(callback: setCallbackFn<any> | setCallbackFnWithThisArg<any>, thisArg: Object?): ()
	if typeof(callback) ~= "function" then
		error("callback is not a function")
	end

	-- note: we can't turn this into a simple for-in loop, because the callbacks can modify the table and React, GQL, and Jest rely on JS behavior in that scenario
	arrayForEach(self._array, function(value)
		if thisArg ~= nil then
			(callback :: setCallbackFnWithThisArg<any>)(thisArg, value, value, self)
		else
			(callback :: setCallbackFn<any>)(value, value, self)
		end
	end)
end

function Set:has(value): boolean
	return self._map[value] ~= nil
end

function Set:ipairs()
	if _G.__DEV__ then
		warn(
			debug.traceback(
				"`for _,_ in mySet:ipairs() do` is deprecated and will be removed in a future release, please use `for _,_ in mySet do` instead\n",
				2
			)
		)
	end
	return ipairs(self._array)
end

return Set
--Still Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill--Still Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill
--Still Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill till Chill
-- Hook events


Entry.TextBox.FocusLost:Connect(function(submit)
	return Window:LoseFocus(submit)
end)

UserInputService.InputBegan:Connect(function(input, gameProcessed)
	return Window:BeginInput(input, gameProcessed)
end)

Entry.TextBox:GetPropertyChangedSignal("Text"):Connect(function()
	if Entry.TextBox.Text:match("\t") then -- Eat \t
		Entry.TextBox.Text = Entry.TextBox.Text:gsub("\t", "")
		return
	end
	if Window.OnTextChanged then
		return Window.OnTextChanged(Entry.TextBox.Text)
	end
end)

Gui.ChildAdded:Connect(Window.UpdateWindowHeight)

return Window
--[=[
	Checks whether the given object is a Promise via duck typing. This only checks if the object is a table and has an `andThen` method.

	@param object any
	@return boolean -- `true` if the given `object` is a Promise.
]=]


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
-- From a LocalScript


local Knit = require(game:GetService("ReplicatedStorage").Knit)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PointsService = Knit.GetService("PointsService")
local CameraController = Knit.GetService("CameraController")

Knit.AddControllers(ReplicatedStorage.Services.ClientControllers)

local function PointsChanged(points)
	print("My points:", points)
end
--[[Steering]]


	Tune.SteerInner		= 35		-- Inner wheel steering angle (in degrees)
	Tune.SteerOuter		= 35		-- Outer wheel steering angle (in degrees)
	Tune.SteerSpeed		= .05		-- Steering increment per tick (in degrees)
	Tune.ReturnSpeed	= .1		-- Steering increment per tick (in degrees)
	Tune.SteerDecay		= 320		-- Speed of gradient cutoff (in SPS)
	Tune.MinSteer		= 10		-- Minimum steering at max steer decay (in percent)
	Tune.MSteerExp		= 1			-- Mouse steering exponential degree
	
	--Steer Gyro Tuning
	Tune.SteerD			= 1000		-- Steering Dampening
	Tune.SteerMaxTorque	= 50000		-- Steering Force
	Tune.SteerP			= 100000	-- Steering Aggressiveness
--[[ Script Variables ]]

--
while not Players.LocalPlayer do
	wait()
end
local LocalPlayer = Players.LocalPlayer
local Mouse = LocalPlayer:GetMouse()
local PlayerGui = LocalPlayer:WaitForChild('PlayerGui')
local ScreenGui = nil
local ShiftLockIcon = nil
local IsShiftLockMode = false
local IsShiftLocked = false
local IsActionBound = false