Pinkstack/roblox-luau-corpus-text huggingface dataset:
-- Compiled with roblox-ts v2.1.0


local TS = require(game:GetService("ReplicatedStorage"):WaitForChild("rbxts_include"):WaitForChild("RuntimeLib"))
local Players = TS.import(script, game:GetService("ReplicatedStorage"), "rbxts_include", "node_modules", "@rbxts", "services").Players
local Client = TS.import(script, game:GetService("ReplicatedStorage"), "TS", "components").Client
local player = Players.LocalPlayer
local function client(world, state)
	for id, client in world:queryChanged(Client) do
		if not client.old and (client.new and client.new.player.UserId == player.UserId) then
			state.playerId = id
			return nil
		end
	end
end
return client
----- cold tap handler -----



coldTap.Interactive.ClickDetector.MouseClick:Connect(function()
	if coldOn.Value == false then
		coldOn.Value = true
		faucet.ParticleEmitter.Enabled = true
		waterSound:Play()
		hotTap.Interactive.ClickDetector.MaxActivationDistance = 0
		coldTap.Interactive.ClickDetector.MaxActivationDistance = 32
		hotTap.Handle.Transparency = 1
		coldTap.Handle.Transparency = 0
		handle.HandleOff.Transparency = 1
	else
		coldOn.Value = false
		if hotOn.Value == false then
			faucet.ParticleEmitter.Enabled = false
			waterSound:Stop()
		end
		hotTap.Interactive.ClickDetector.MaxActivationDistance = 32
		coldTap.Interactive.ClickDetector.MaxActivationDistance = 32
		hotTap.Handle.Transparency = 1
		coldTap.Handle.Transparency = 1
		handle.HandleOff.Transparency = 0
	end
end)
--[[
	Add a dummy child node to the current node to hold the given error. This
	allows an otherwise empty describe node to report an error in a more natural
	way.
]]


function TestSession:addDummyError(phrase, message)
	self:pushNode({ type = TestEnum.NodeType.It, phrase = phrase })
	self:setError(message)
	self:popNode()
	self.nodeStack[#self.nodeStack].status = TestEnum.TestStatus.Failure
end
--[[Driver Handling]]



	--Driver Sit	
	car.DriveSeat.ChildAdded:connect(function(child)
		if child.Name=="SeatWeld" and child:IsA("Weld") and game.Players:GetPlayerFromCharacter(child.Part1.Parent)~=nil then
			--Distribute Client Interface
			local p=game.Players:GetPlayerFromCharacter(child.Part1.Parent)
			car.DriveSeat:SetNetworkOwner(p)
			local g=script.Parent["A-Chassis Interface"]:Clone()
			g.Parent=p.PlayerGui
			script.Parent.Parent.Body.Raycaster.Script.Values.Value = g
		end
	end)
	
	--Driver Leave
	car.DriveSeat.ChildRemoved:connect(function(child)
		if child.Name=="SeatWeld" and child:IsA("Weld") then
			--Remove Flip Force
			if car.DriveSeat:FindFirstChild("Flip")~=nil then
				car.DriveSeat.Flip.MaxTorque = Vector3.new()
			end
			
			--Remove Wheel Force
			for i,v in pairs(car.Wheels:GetChildren()) do
				if v:FindFirstChild("#AV")~=nil then
					if v["#AV"]:IsA("BodyAngularVelocity") then
						if v["#AV"].AngularVelocity.Magnitude>0 then
							v["#AV"].AngularVelocity = Vector3.new()
							v["#AV"].MaxTorque = Vector3.new()
						end
					else
						if v["#AV"].AngularVelocity>0 then
							v["#AV"].AngularVelocity = 0
							v["#AV"].MotorMaxTorque = 0
						end
					end
				end
			end
		end
	end)
-- ScriptSignal object:



local ScriptSignal = {
	--[[
		_head = nil,
		_listener_count = 0,
	--]]
}
ScriptSignal.__index = ScriptSignal

function ScriptSignal:Connect(listener, disconnect_listener, disconnect_param) --> [ScriptConnection]

	local script_connection = {
		_listener = listener,
		_script_signal = self,
		_disconnect_listener = disconnect_listener,
		_disconnect_param = disconnect_param,

		_next = self._head,
		_is_connected = true,
	}
	setmetatable(script_connection, ScriptConnection)

	self._head = script_connection
	self._listener_count += 1

	return script_connection

end

function ScriptSignal:GetListenerCount() --> [number]
	return self._listener_count
end

function ScriptSignal:Fire(...)
	local item = self._head
	while item ~= nil do
		if item._is_connected == true then
			if not FreeRunnerThread then
				FreeRunnerThread = coroutine.create(RunEventHandlerInFreeThread)
			end
			task.spawn(FreeRunnerThread, item._listener, ...)
		end
		item = item._next
	end
end

function ScriptSignal:FireUntil(continue_callback, ...)
	local item = self._head
	while item ~= nil do
		if item._is_connected == true then
			item._listener(...)
			if continue_callback() ~= true then
				return
			end
		end
		item = item._next
	end
end

function MadworkScriptSignal.NewScriptSignal() --> [ScriptSignal]
	return {
		_head = nil,
		_listener_count = 0,
		Connect = ScriptSignal.Connect,
		GetListenerCount = ScriptSignal.GetListenerCount,
		Fire = ScriptSignal.Fire,
		FireUntil = ScriptSignal.FireUntil,
	}
end

return MadworkScriptSignal
--// All global vars will be wiped/replaced except script



return function(data, env)
	if env then
		setfenv(1, env)
	end

	local UI = client.UI

	local gui = service.New("ScreenGui", {ResetOnSpawn = false})
	local gTable = UI.Register(gui)

	if UI.Get("HelpButton", gui, true) then
		gui:Destroy()
		gTable:Destroy()
		return nil
	end

	gTable.Name = "HelpButton"
	gTable.CanKeepAlive = true

	local toggle = service.New("ImageButton", {
		Parent = gui;
		Name = "Toggle";
		BackgroundTransparency = 1;
		Position = UDim2.new(1, -45, 1, -45);
		Size = UDim2.fromOffset(40, 40);
		Image = client.HelpButtonImage;
		ImageTransparency = 0.5;
	})

	--if UI.Get("Chat") then
	--	toggle.Position = UDim2.new(1, -(45+40),1, -45)
	--end

	toggle.MouseButton1Down:Connect(function()
		local found = UI.Get("UserPanel", nil, true)
		if found then
			found.Object:Destroy()
		else
			UI.Make("UserPanel")
		end
	end)

	gTable:Ready()
end
----- Frames -----



local GiftFrame = ScreenGui.ClaimGift.GiftFrame
local DailyRewardFrame = ScreenGui.DailyReward.DailyRewardFrame
local RebirthFrame = ScreenGui.Rebirth.RebirthFrame
local StoreFrame = ScreenGui.Store.StoreFrame
local VipFrame = ScreenGui.VIP.VipFrame
local InventoryFrame = ScreenGui.Inventory.InventoryFrame
local CaseStoreFrame = ScreenGui.CaseShop.CaseShopFrame
--m3.Volume = 0


m2.Looped = false
m2.Playing = false
script.Parent.Parent:WaitForChild("Drive").Locotrol.Event:connect(function(data)
	if data["Horn"] == true then
		m2.Volume = 0
		m2.Looped = false
		m2:Stop()
		m2.Playing = false
		--m3.Volume = 0
		--m3.Stop()
		m1.Volume = 7.5
		m1:Play()
		--wait(m1.TimeLength) --disabled because it makes looping part stuck playing if stopped too soon.
		if m1.TimePosition < m1.TimeLength then
			m2.Looped = true
			m2.Volume = 7.5
			m2:Play()
		else
			m1.Volume = 0
			m1:Stop()
		end
	elseif data["Horn"] == false then
		m1.Volume = 0
		m1:Stop()
		--[[ --For 3 part option
		m2.Volume = 0
		m2:Stop()
		m2.Looped = false
		m2.Playing = false
		m3.Volume = 1
		m3:Play()
		--]]
		----[[ -- For 2 part option
		if m2.IsPlaying == true then
			for i=2, 0, -.2 do
				m2.Volume = i*1
				wait(.1)
			end
		end
		m2.Volume = 0
		m2.Looped = false
		m2.Playing = false
		m2:Stop()
		----]]	
	end
end)
-- PRIVATE FUNCTIONS


function ZoneController._registerZone(zone)
   	registeredZones[zone] = true
	local registeredMaid = zone._maid:give(Maid.new())
	zone._registeredMaid = registeredMaid
	registeredMaid:give(zone.updated:Connect(function()
		ZoneController._updateZoneDetails()
	end))
   ZoneController._updateZoneDetails()
end

function ZoneController._deregisterZone(zone)
	registeredZones[zone] = nil
	zone._registeredMaid:clean()
	zone._registeredMaid = nil
	ZoneController._updateZoneDetails()
end

function ZoneController._registerConnection(registeredZone, registeredTriggerType)
	local originalItems = dictLength(registeredZone.activeTriggers)
	activeConnections += 1
	if originalItems == 0 then
		activeZones[registeredZone] = true
		ZoneController._updateZoneDetails()
	end
	local currentTriggerCount = activeTriggers[registeredTriggerType]
	activeTriggers[registeredTriggerType] = (currentTriggerCount and currentTriggerCount+1) or 1
	registeredZone.activeTriggers[registeredTriggerType] = true
	if registeredZone.touchedConnectionActions[registeredTriggerType] then
		registeredZone:_formTouchedConnection(registeredTriggerType)
	end
	if heartbeatActions[registeredTriggerType] then
		ZoneController._formHeartbeat(registeredTriggerType)
	end
end
--[[
    Create a ClientAvatarComponent for the given model
]]


function ClientAvatarComponent.new(model, userId)
	local component = {
		model = model
	}
	setmetatable(component, {__index = ClientAvatarComponent})

	local avatar = model:FindFirstChild(ReplicatedConstants.AVATAR_MODEL_NAME)
	component.avatar = avatar

	component:setupJoints()

	return component
end
-- same as jump for now



function moveFreeFall()
	RightShoulder.MaxVelocity = 0.5
	LeftShoulder.MaxVelocity = 0.5
	RightShoulder.DesiredAngle = (3.14)
	LeftShoulder.DesiredAngle = (-3.14)
	RightHip.DesiredAngle = (0)
	LeftHip.DesiredAngle = (0)
end

function moveSit()
	RightShoulder.MaxVelocity = 0.15
	LeftShoulder.MaxVelocity = 0.15
	RightShoulder.DesiredAngle = (3.14 /2)
	LeftShoulder.DesiredAngle = (-3.14 /2)
	RightHip.DesiredAngle = (3.14 /2)
	LeftHip.DesiredAngle = (-3.14 /2)
end

function getTool()	
	for _, kid in ipairs(Figure:GetChildren()) do
		if kid.className == "Tool" then return kid end
	end
	return nil
end

function getToolAnim(tool)
	for _, c in ipairs(tool:GetChildren()) do
		if c.Name == "toolanim" and c.className == "StringValue" then
			return c
		end
	end
	return nil
end

function animateTool()
	
	if (toolAnim == "None") then
		RightShoulder.DesiredAngle = (1.57)
		return
	end

	if (toolAnim == "Slash") then
		RightShoulder.MaxVelocity = 0.5
		RightShoulder.DesiredAngle = (0)
		return
	end

	if (toolAnim == "Lunge") then
		RightShoulder.MaxVelocity = 0.5
		LeftShoulder.MaxVelocity = 0.5
		RightHip.MaxVelocity = 0.5
		LeftHip.MaxVelocity = 0.5
		RightShoulder.DesiredAngle = (1.57)
		LeftShoulder.DesiredAngle = (1.0)
		RightHip.DesiredAngle = (1.57)
		LeftHip.DesiredAngle = (1.0)
		return
	end
end

function move(time)
	local amplitude
	local frequency
  
	if (pose == "Jumping") then
		moveJump()
		return
	end

	if (pose == "FreeFall") then
		moveFreeFall()
		return
	end
 
	if (pose == "Seated") then
		moveSit()
		return
	end

	local climbFudge = 0
	
	if (pose == "Running") then
		RightShoulder.MaxVelocity = 0.15
		LeftShoulder.MaxVelocity = 0.15
		amplitude = 1
		frequency = 9
	elseif (pose == "Climbing") then
		RightShoulder.MaxVelocity = 0.5 
		LeftShoulder.MaxVelocity = 0.5
		amplitude = 1
		frequency = 9
		climbFudge = 3.14
	else
		amplitude = 0.1
		frequency = 1
	end

	desiredAngle = amplitude * math.sin(time*frequency)

	RightShoulder.DesiredAngle = (desiredAngle + climbFudge)
	LeftShoulder.DesiredAngle = (desiredAngle - climbFudge)
	RightHip.DesiredAngle = (-desiredAngle)
	LeftHip.DesiredAngle = (-desiredAngle)


	local tool = getTool()

	if tool then
	
		animStringValueObject = getToolAnim(tool)

		if animStringValueObject then
			toolAnim = animStringValueObject.Value
			-- message recieved, delete StringValue
			animStringValueObject.Parent = nil
			toolAnimTime = time + .3
		end

		if time > toolAnimTime then
			toolAnimTime = 0
			toolAnim = "None"
		end

		animateTool()

		
	else
		toolAnim = "None"
		toolAnimTime = 0
	end
end
--script.Parent.CCC.Velocity = script.Parent.CCC.CFrame.lookVector *script.Parent.Speed.Value


script.Parent.CCCC.Velocity = script.Parent.CCCC.CFrame.lookVector *script.Parent.Speed.Value
script.Parent.D.Velocity = script.Parent.D.CFrame.lookVector *script.Parent.Speed.Value
script.Parent.DD.Velocity = script.Parent.DD.CFrame.lookVector *script.Parent.Speed.Value
script.Parent.DDD.Velocity = script.Parent.DDD.CFrame.lookVector *script.Parent.Speed.Value
script.Parent.DDDD.Velocity = script.Parent.DDDD.CFrame.lookVector *script.Parent.Speed.Value
script.Parent.E.Velocity = script.Parent.E.CFrame.lookVector *script.Parent.Speed.Value
-- Battery1 --



Battery.Interaction.Touched:Connect(function(hit)
	if hit.Parent:IsA("Tool") and hit.Parent.Name == ToolRequired then
		Battery.Battery1.Transparency = 0
		if game.ReplicatedStorage.ItemSwitching.Value == true then
			hit.Parent:Destroy()
		end
		Battery.Parent.SoundPart.Insert:Play()
		Battery.Parent.Light2.Color = Color3.fromRGB(0,255,0)
		LocksLeft.Value = LocksLeft.Value - 1
		Battery.Battery1Script.Disabled = true
	end
end)

Battery.Interaction.ClickDetector.MouseClick:Connect(function(plr)
	if plr.Backpack:FindFirstChild(Battery.ToolRequired.Value) then
		Battery.Battery1.Transparency = 0
		if game.ReplicatedStorage.ItemSwitching.Value == true then
			plr.Backpack:FindFirstChild(ToolRequired):Destroy()
		end
		Battery.Parent.SoundPart.Insert:Play()
		Battery.Parent.Light2.Color = Color3.fromRGB(0,255,0)
		LocksLeft.Value = LocksLeft.Value - 1
		Battery.Battery1Script.Disabled = true
	end
end)
--[[Running Logic]]

--
local equipped = false
local rayparts = {}
local ColorChoices = {BrickColor.new('Really red'),BrickColor.new('Lime green'),BrickColor.new('Toothpaste')}
local StartOffset = {Vector3.new(-.45,0,0),Vector3.new(0,0,0),Vector3.new(.45,0,0)}
local oldC0 =nil
local nweld
local EffectFunctions = 
{
	function(hum,dir) hum:TakeDamage(1) end,
	function(hum,dir) hum:TakeDamage(-1) end,
	function(hum,dir) 
		if hum.Torso then
			local nforce = Instance.new('BodyForce')
			nforce.force = dir*100
			nforce.Parent = hum.Torso
			hum.Sit = true
			game.Debris:AddItem(nforce,.2)
			Delay(.2,function() hum.Sit = false end)
		end
	end
}
Tool.Equipped:connect(function(mouse)
	--game.Players.LocalPlayer:GetMouse()
	Spawn(function()
		local colorChoice = 1
		if not Tool.Parent:FindFirstChild('Torso') or not Tool.Parent.Torso:FindFirstChild('Right Shoulder') or not Tool.Parent:FindFirstChild('Humanoid') then return end
		LazerSound:Play()
		nweld = Tool.Parent.Torso['Right Shoulder']
		oldC0 = nweld.C0
		nweld.CurrentAngle = 0
		nweld.DesiredAngle = 0
		nweld.MaxVelocity = 0
		mouse.Button1Down:connect(function()
			colorChoice=colorChoice+1
			if colorChoice>#ColorChoices then colorChoice =1 end
			LazerSound.Pitch = .75+((colorChoice*.25)*3)
		end)
		equipped = true
		while equipped and Tool.Parent:FindFirstChild('Torso') do
			local tframe = Tool.Parent.Torso.CFrame
			tframe = tframe + tframe:vectorToWorldSpace(Vector3.new(1, 0.5, 0))
			local taim = mouse.Hit.p -( tframe.p )
			nweld.C0 = (CFrame.new(Vector3.new(),tframe:vectorToObjectSpace(taim))*CFrame.Angles(0,math.pi/2,0))+Vector3.new( 1, 0.5, 0 )
			rayparts = CastLightRay(Handle.CFrame.p+Handle.CFrame:vectorToWorldSpace(StartOffset[colorChoice]),mouse.Hit.p,ColorChoices[colorChoice], 5, .2,rayparts, EffectFunctions[colorChoice])
			LazerSound.Volume = ((math.sin(tick()*3)+1)*.25)+.25
			wait()
		end
		nweld.C0 =oldC0
		LazerSound:Stop()
	end)
end)

Tool.Unequipped:connect(function(mouse)
	equipped= false
	LazerSound:Stop()
	for i=1,50,1 do
		if rayparts[i] then
			rayparts[i]:Destroy()
			rayparts[i]=nil		
		end
	end
	if nweld then
		nweld.MaxVelocity =.15
		nweld.C0 =oldC0
	end
	
end)
--


Edit = {
U = {{CFrame.new(0,0.03*(3.5/TimeOpen),0),TimeOpen*SL}},
D = {{CFrame.new(0,-0.03*(3.5/TimeOpen),0),TimeOpen*SL}},
R = {{CFrame.new(-0.03*(3.5/TimeOpen),0,0),TimeOpen*SL,TimeOpen}},
L = {{CFrame.new(0.03*(3.5/TimeOpen),0,0),TimeOpen*SL,TimeOpen}},
}
WaitTime = 7.5
-- Adds numParts more parts to the cache.


function PartCacheStatic:Expand(numParts: number): ()
	assert(getmetatable(self) == PartCacheStatic, ERR_NOT_INSTANCE:format("Expand", "PartCache.new"))
	if numParts == nil then
		numParts = self.ExpansionSize
	end

	for i = 1, numParts do
		table.insert(self.Open, MakeFromTemplate(self.Template, self.CurrentCacheParent))
	end
end
--DO NOT CHANGE ANYTHING INSIDE OF THIS SCRIPT BESIDES WHAT YOU ARE TOLD TO UNLESS YOU KNOW WHAT YOU'RE DOING OR THE SCRIPT WILL NOT WORK!!


local hitPart = script.Parent
local debounce = true
local tool = game.ServerStorage.SuperSpeedRibbon -- Change "Sword" to the name of your tool, make sure your tool is in ServerStorage

hitPart.Touched:Connect(function(hit)
	if debounce == true then
		if hit.Parent:FindFirstChild("Humanoid") then
			local plr = game.Players:FindFirstChild(hit.Parent.Name)
			if plr then
				debounce = false
				hitPart.BrickColor = BrickColor.new("Bright red")
				tool:Clone().Parent = plr.Backpack
				wait(3) -- Change "3" to however long you want the player to have to wait before they can get the tool again
				debounce = true
				hitPart.BrickColor = BrickColor.new("Bright green")
			end
		end
	end
end)
--This will change all player's characters into R6 1.0.
--You can either modify this script or use another script to change the player's 'package'.


script:WaitForChild("R6 Camera").Parent = game.StarterPlayer.StarterPlayerScripts
script:WaitForChild("R6").Parent = game:GetService("ReplicatedStorage")
game.Players.PlayerAdded:connect(function(p)
	p.CharacterAdded:connect(function(c)
		if not p.Character:FindFirstChild("R6") then
			game.Workspace:WaitForChild(p.Name)
			local r = game:GetService("ReplicatedStorage"):WaitForChild("R6"):Clone()
			r.Name = p.Name
			r.Parent = game.Workspace
			r.HumanoidRootPart.CFrame = CFrame.new(c.HumanoidRootPart.Position)
			r:WaitForChild("Body Colors")
			c:WaitForChild("Body Colors")
			local b1 = r["Body Colors"]
			local b2 = c["Body Colors"]
			b1.HeadColor = b2.HeadColor
			b1.LeftArmColor = b2.LeftArmColor
			b1.LeftLegColor = b2.LeftLegColor
			b1.RightArmColor = b2.RightArmColor
			b1.RightLegColor = b2.RightLegColor
			b1.TorsoColor = b2.TorsoColor
			r:WaitForChild("Head"):WaitForChild("face").Texture = c.Head.face.Texture
			for _,h in pairs(c:GetChildren()) do
				if h.ClassName == "Accessory" or h.ClassName == "Hat" or h.ClassName == "Shirt" or h.ClassName == "Pants" or h.ClassName == "Shirt Graphic" then
					h.Parent = game.Workspace
					h.Parent = r
				end
			end
			c:Destroy()
			p.Character = r
			wait()
			p.Character:WaitForChild("Animate").Disabled = false
		end
	end)
end)
-----------------
--| Constants |--
-----------------



local GRAVITY_ACCELERATION = workspace.Gravity

local RELOAD_TIME = 3 -- Seconds until tool can be used again
local ROCKET_SPEED = 80 -- Speed of the projectile

local MISSILE_MESH_ID = 'http://www.roblox.com/asset/?id=2251534'
local MISSILE_MESH_SCALE = Vector3.new(0.35, 0.35, 0.25)
local ROCKET_PART_SIZE = Vector3.new(1.2, 1.2, 3.27)
--!strict
--[=[
  @function merge
  @within Set

  @param ... ...any -- The sets to merge.
  @return { [T]: boolean } -- The merged set.

  Combines one or more sets into a single set.

  Aliases: `join`, `union`

  ```lua
  local set1 = { hello = true, world = true }
  local set2 = { cat = true, dog = true, hello = true }

  local merge = Merge(set1, set2) -- { hello = true, world = true, cat = true, dog = true }
  ```
]=]


local function merge<T>(...: any): { [T]: boolean }
	local result = {}

	for setIndex = 1, select("#", ...) do
		local set = select(setIndex, ...)

		if type(set) ~= "table" then
			continue
		end

		for key, _ in pairs(set) do
			result[key] = true
		end
	end

	return result
end

return merge
--edit the function below to return true when you want this response/prompt to be valid
--player is the player speaking to the dialogue, and dialogueFolder is the object containing the dialogue data


return function(player, dialogueFolder)
	local plrData = require(game.ReplicatedStorage.Source.Modules.Util):GetPlayerData(player)
	return plrData.Classes.Base.Smasher.Obtained.Value == false
end
-- ROBLOX deviation: ansi-styles not ported



local CurrentModule = script
local Packages = CurrentModule.Parent

local LuauPolyfill = require(Packages.LuauPolyfill)
local Error = LuauPolyfill.Error
local Object = LuauPolyfill.Object
local extends = LuauPolyfill.extends
local isNaN = LuauPolyfill.Number.isNaN

local Collections = require(CurrentModule.Collections)
local printTableEntries = Collections.printTableEntries
local printListItems = Collections.printListItems

local AsymmetricMatcher = require(CurrentModule.plugins.AsymmetricMatcher)
local ConvertAnsi = require(CurrentModule.plugins.ConvertAnsi)
local RobloxInstance = require(CurrentModule.plugins.RobloxInstance)
local ReactElement = require(CurrentModule.plugins.ReactElement)
local ReactTestComponent = require(CurrentModule.plugins.ReactTestComponent)

local JestGetType = require(Packages.JestGetType)
local getType = JestGetType.getType
local isRobloxBuiltin = JestGetType.isRobloxBuiltin

local Types = require(CurrentModule.Types)
export type Colors = Types.Colors
export type CompareKeys = Types.CompareKeys
export type Config = Types.Config
export type Options = Types.Options
export type OptionsReceived = Types.OptionsReceived
export type OldPlugin = Types.OldPlugin
export type NewPlugin = Types.NewPlugin
export type Plugin = Types.Plugin
export type Plugins = Types.Plugins
export type PrettyFormatOptions = Types.PrettyFormatOptions
export type Printer = Types.Printer
export type Refs = Types.Refs
export type Theme = Types.Theme

local PrettyFormatPluginError = extends(Error, "PrettyFormatPluginError", function(self, message)
	self.name = "PrettyFormatPluginError"
	self.message = message
end)
-- Given a part, will return return the character from the given part.


function PartUtility.GetCharacterFromInstance_R(part)
	local model = part:FindFirstAncestorOfClass("Model")
	if model and model:FindFirstChild("Humanoid") then
		return model
	elseif model then
		PartUtility.GetCharacterFromInstance_R(model)
	end
end

function PartUtility.MakeInvisible(model)
	for _, child in pairs(model:GetDescendants()) do
		if child:IsA("BasePart") then
			child:SetAttribute("InitialTransparency",child.Transparency)
			child.Transparency = 1
		end
	end
end

function PartUtility.RestoreVisibility(model)
	for _, child in pairs(model:GetDescendants()) do
		if child:IsA("BasePart") then
			child.Transparency = child:GetAttribute("InitialTransparency") and child:GetAttribute("InitialTransparency") or 0
		end
	end
end

function PartUtility.MakeVisible(model)
	for _, child in pairs(model:GetDescendants()) do
		if child:IsA("BasePart") then
			child.Transparency = 0
		end
	end
end

return PartUtility
----- Connections -----



Players.PlayerAdded:Connect(function(player)
	PlayerReference[player] = true
end)

Players.PlayerRemoving:Connect(function(player)
	PlayerReference[player] = nil
	-- Automatic player reference cleanup:
	for rate_limiter in pairs(RateLimiters) do
		rate_limiter._sources[player] = nil
	end
end)

return RateLimiter
-- Copied from GenericButton. TODO: factor it out


return function(contentMap, controlState, style)
	local contentThemeClass = contentMap[controlState]
		or contentMap[ControlState.Default]

	local contentStyle = {
		Color = style.Theme[contentThemeClass].Color,
		Transparency = style.Theme[contentThemeClass].Transparency,
	}

	--Based on the design specs, the disabled and pressed state is 0.5 * alpha value
	if controlState == ControlState.Disabled or
		controlState == ControlState.Pressed then
			contentStyle.Transparency = 0.5 * contentStyle.Transparency + 0.5
	end
	return contentStyle
end