Pinkstack/roblox-luau-corpus-text huggingface dataset:
--[[
	Utility function to log a Fusion-specific error.
]]


local Package = script.Parent.Parent
local Types = require(Package.Types)
local messages = require(Package.Logging.messages)

local function logError(messageID: string, errObj: Types.Error?, ...)
	local formatString = messages[messageID]

	if formatString == nil then
		messageID = "unknownMessage"
		formatString = messages[messageID]
	end

	local errorString
	if errObj == nil then
		errorString = string.format("[Fusion] " .. formatString .. "\n(ID: " .. messageID .. ")", ...)
	else
		formatString = formatString:gsub("ERROR_MESSAGE", errObj.message)
		errorString = string.format("[Fusion] " .. formatString .. "\n(ID: " .. messageID .. ")\n---- Stack trace ----\n" .. errObj.trace, ...)
	end

	error(errorString:gsub("\n", "\n    "), 0)
end

return logError
-- ROBLOX FIXME: add type constraint <EachCallback extends TestCallback>


type Each<EachCallback> =
	((table: EachTable, ...any) -> ((title: string, test: EachTestFn<EachCallback>, timeout: number?) -> ()))
	| (() -> () -> ())

export type HookBase = (testName: TestName, fn: TestFn, timeout: number?) -> ()

export type ItBase = typeof(setmetatable({} :: { each: Each<TestFn> }, {
	__call = function(_, testName: TestName, fn: TestFn, timeout: number?): () end,
}))

export type It = ItBase & { only: ItBase, skip: ItBase, todo: (testName: TestName) -> () }

export type ItConcurrentBase = typeof(setmetatable({} :: { each: Each<ConcurrentTestFn> }, {
	__call = function(_, testName: string, testFn: ConcurrentTestFn, timeout: number?): () end,
}))

export type ItConcurrentExtended = ItConcurrentBase & { only: ItConcurrentBase, skip: ItConcurrentBase }

export type ItConcurrent = It & { concurrent: ItConcurrentExtended }

export type DescribeBase = typeof(setmetatable({} :: { each: Each<BlockFn> }, {
	__call = function(_, blockName: BlockName, blockFn: BlockFn): () end,
}))

export type Describe = DescribeBase & { only: DescribeBase, skip: DescribeBase }

export type TestFrameworkGlobals = {
	it: ItConcurrent,
	test: ItConcurrent,
	fit: ItBase & { concurrent: ItConcurrentBase? },
	xit: ItBase,
	xtest: ItBase,
	describe: Describe,
	xdescribe: DescribeBase,
	fdescribe: DescribeBase,
	beforeAll: HookBase,
	beforeEach: HookBase,
	afterEach: HookBase,
	afterAll: HookBase,
}

export type GlobalAdditions = TestFrameworkGlobals & {
	__coverage__: CoverageMapData,
	jasmine: Jasmine,
	fail: () -> (),
	pending: () -> (),
	spyOn: () -> (),
	spyOnProperty: () -> (),
}
-- FUNCTIONS


function CollectiveWorldModel.setupWorldModel(zone)
	if worldModel then
		return worldModel
	end
	local location = (runService:IsClient() and "ReplicatedStorage") or "ServerStorage"
	worldModel = Instance.new("WorldModel")
	worldModel.Name = "ZonePlusWorldModel"
	worldModel.Parent = game:GetService(location)
	return worldModel
end
--<DON'T TOUCH THE SCRIPT UNLESS YOU KNOW WHAT YOU ARE DOING!



local RS = game:GetService('ReplicatedStorage')
local TS = game:GetService('TweenService')

local Tool = script.Parent
local TextureArray = {}

local Activated = false
local Debounce = false
local Cooldown = 1
local Prop = nil
local LaughAnim = nil

Tool.Activated:Connect(function()
	if not Debounce then
		Debounce = true
		task.delay(Cooldown, function()
			Debounce = false
		end)
		
		local Character = Tool.Parent
		
		if not Activated then
			Activated = true
			
			LaughAnim = Character.Humanoid:LoadAnimation(RS.MinkV4.Laugh)
			LaughAnim:Play()
			Character.HumanoidRootPart.Anchored = true
			
			Prop = RS.MinkV4.Props.Tail:Clone()
			Prop.Parent = Character
	 
			local Attachment = Instance.new('Attachment')
			Attachment.Parent = Character.HumanoidRootPart
			Attachment.Position = Vector3.new(0,-2.5,0)

			local Wave = RS.MinkV4.Effects.Wave:Clone()
			Wave.Parent = Attachment

			local Smoke = RS.MinkV4.Effects.Smoke:Clone()
			Smoke.Parent = Character.HumanoidRootPart

			local Pixel = RS.MinkV4.Effects.Pixel:Clone()
			Pixel.Parent = Character.HumanoidRootPart

			local Laugh = RS.MinkV4.Sound.Laugh:Clone()
			Laugh.Parent = Character.HumanoidRootPart

			local SmokeSound = RS.MinkV4.Sound.Smoke:Clone()
			SmokeSound.Parent = Character.HumanoidRootPart

			Laugh:Play()

			task.delay(1.6,function()
				Laugh:Destroy()
				task.wait(0.25)
				Character.HumanoidRootPart.Anchored = false
				LaughAnim:Stop()
			end)

			SmokeSound:Play()

			local Tween = TS:Create(SmokeSound, TweenInfo.new(1.5), {Volume = 0})
			Tween:Play()

			Tween.Completed:Connect(function()
				SmokeSound:Destroy()
			end)	

			Wave:Emit(2)
			Smoke:Emit(100)
			Pixel:Emit(50)

			for _, Item in ipairs(Character.Humanoid:GetAccessories()) do
				local Hair = Item.Handle:FindFirstChild("HairAttachment") ~= nil
				if Hair then
					TextureArray[Item] = {TextureID = Item.Handle.TextureID, Color = Item.Handle.Color, Material = Item.Handle.Material}
					Item.Handle.Color = Color3.fromRGB(168, 168, 168)
					Item.Handle.TextureID = ''
					Item.Handle.Material = Enum.Material.Neon
				end
			end
			
		elseif Activated then
			Activated = false
			
			local Tween = TS:Create(Prop.Handle, TweenInfo.new(0.5), {Transparency = 1})
			Tween:Play()

			Tween.Completed:Connect(function()
				Prop:Destroy()
			end)
			
			for _, Item in ipairs(Character.Humanoid:GetAccessories()) do
				local Hair = Item.Handle:FindFirstChild("HairAttachment") ~= nil
				if Hair then
					Item.Handle.Color = TextureArray[Item].Color
					Item.Handle.Material = TextureArray[Item].Material
					Item.Handle.TextureID = TextureArray[Item].TextureID
					TextureArray[Item] = nil
				end
			end
		end
	end
end)
-- If you want to know how to retexture a hat, read this:  http://www.roblox.com/Forum/ShowPost.aspx?PostID=10502388










debounce = true

function onTouched(hit)
	if (hit.Parent:findFirstChild("Humanoid") ~= nil and debounce == true) then
		debounce = false
		h = Instance.new("Accessory")
		p = Instance.new("Part")
		h.Name = "Hat"   -- It doesn't make a difference, but if you want to make your place in Explorer neater, change this to the name of your hat.
		p.Parent = h
		p.Position = hit.Parent:findFirstChild("Head").Position
		p.Name = "Handle" 
		p.formFactor = 0
		p.Size = Vector3.new(-0,-0,-1) 
		p.BottomSurface = 0 
		p.TopSurface = 0 
		p.Locked = true 
		script.Parent.Mesh:clone().Parent = p
		h.Parent = hit.Parent
		h.AttachmentPos = Vector3.new(0,0.125,-0.325) -- Change these to change the positiones of your hat, as I said earlier.
		wait(5)		debounce = true
	end
end

script.Parent.Touched:connect(onTouched)
-- Called when the user's rotation type is changed.
-- This is a strong indication the user is in first person
-- and needs to have its first person movement smoothened out.



function FpsCamera:OnRotationTypeChanged()
	local camera = workspace.CurrentCamera
	local subject = camera and camera.CameraSubject
	
	if subject and subject:IsA("Humanoid") then
		local rotationType = UserGameSettings.RotationType
	
		if rotationType == Enum.RotationType.CameraRelative then
			subject.AutoRotate = false
			
			RunService:BindToRenderStep("FpsCamera", 1000, function (delta)
				if subject.AutoRotate or not subject:IsDescendantOf(game) or (subject.SeatPart and subject.SeatPart:IsA("VehicleSeat")) then
					RunService:UnbindFromRenderStep("FpsCamera")
					return
				end

				if camera.CameraType.Name == "Scriptable" then
					return
				end
				
				local rootPart = subject.RootPart
				local isGrounded = rootPart and rootPart:IsGrounded()
				
				if rootPart and not isGrounded then
					local state = subject:GetState()
					local canRotate = true

					if self.InvalidRotationStates[state.Name] then
						canRotate = false
					end

					if subject.Sit and subject.SeatPart then
						local root = rootPart:GetRootPart()

						if root ~= rootPart then
							canRotate = false
						end
					end

					if canRotate then
						local pos = rootPart.Position
						local step = math.min(0.2, (delta * 40) / 3)

						local look = camera.CFrame.LookVector
						look = (look * XZ_VECTOR3).Unit
						
						local cf = CFrame.new(pos, pos + look)
						rootPart.CFrame = rootPart.CFrame:Lerp(cf, step)
					end
				end

				if self:IsInFirstPerson() then
					local cf = camera.CFrame
					local headPos, headLook = self:GetSubjectPosition(subject)

					if headPos then
						local offset = (headPos - cf.Position)
						cf += offset

						camera.CFrame = cf
						camera.Focus += offset
					end

					local shadowAngle = self:GetShadowAngle()
					local inView = cf.LookVector:Dot(shadowAngle)

					if inView < 0 then
						for real, mirror in pairs(self.HeadMirrors) do
							mirror.CFrame = real.CFrame + (shadowAngle * 9)
						end
					end

					self.MirrorBin.Parent = (inView < 0 and camera or nil)
				else
					self.MirrorBin.Parent = nil
				end
			end)
		else
			subject.AutoRotate = true
			self.MirrorBin.Parent = nil
		end
	end
end
--[[
local shakeMagnitude = 0.5 -- Adjust this to change the intensity of the shake
local shakeSpeed = 0.05 -- Adjust this to change the speed of the shake
local rotationMagnitude = 0.05 -- Adjust this to change the intensity of the rotation*


local Shakes = {}


local Time = 0


local function GenerateShakeValue(shake)
	local Multiplier = shake["TimeLeft"] / shake["Duration"]
	local X = math.noise(Time + math.random(), 0, 0) * shakeMagnitude * Multiplier
	local Y = math.noise(0, Time + math.random(), 0) * shakeMagnitude * Multiplier
	local Z = math.noise(0, 0, Time + math.random()) * shakeMagnitude * Multiplier

	local Pitch = math.noise(Time + math.random(), 0, 0) * rotationMagnitude * Multiplier
	local Yaw = math.noise(0, Time + math.random(), 0) * rotationMagnitude * Multiplier
	local Roll = math.noise(0, 0, Time + math.random()) * rotationMagnitude * Multiplier


	local OffsetVector = Vector3.new(X,Y,Z)
	local CFrameAngles = CFrame.Angles(Pitch, Yaw, Roll)

	return OffsetVector, CFrameAngles
end

local function NewShake(Power, Duration)
	local shake = {}
	shake["Duration"] = Duration
	shake["Power"] = Power
	shake["TimeLeft"] = shake["Duration"]
	table.insert(Shakes, shake)
end




local BShake = GUI.Shake
BShake.MouseButton1Click:Connect(function()
end)




while true do
	local step = RS.RenderStepped:Wait()
	if #Shakes == 0 then continue end
	--print("Shakes happenings !")


	Time = Time + shakeSpeed * step


	--remove time from Shakes
	for i, child in ipairs(Shakes) do
		if child["TimeLeft"] <= 0 then  table.remove(Shakes, table.find(Shakes, child)) continue end
		child["TimeLeft"] -= step
		--print("A SHAKE RIGHT HERE")
	end


	local SumCameraOffset, SumCFrameAngles = Vector3.new(0,0,0), CFrame.Angles(0,0,0)

	for i, child in ipairs(Shakes) do
		local ChildCameraOffset,ChildCFramesAngles = GenerateShakeValue(child)
		print(ChildCameraOffset)
		SumCameraOffset += ChildCameraOffset
		SumCFrameAngles *= ChildCFramesAngles
	end



	--Final step of applying the final camera shake
	--	print(SumCameraOffset)
	--	print(SumCFrameAngles)
	Humanoid.CameraOffset = SumCameraOffset
	workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * SumCFrameAngles
end
--]]
-- Extra padding to pull the camera further back from the viewport object.
--
-- We use the getDepthToFitObject() function to get an accurate depth to push
-- the camera back to fit the object, however this only works at 90 degree
-- rotations.
--
-- Since the camera is constantly rotating around the object, this is just some
-- extra padding to pull the camera back even further so the sides of the object
-- don't clip.


local DEPTH_PADDING = 2 -- studs

local PINCH_DELTA_TO_ZOOM_DELTA = 0.1
-- CONSTANTS



local CONSTANTS = require(script.Parent:WaitForChild("CONSTANTS"))
local Triangle = require(script.Parent:WaitForChild("Triangle"))

local PI2 = math.pi/2
local TAU = CONSTANTS.TAU

local GAP = CONSTANTS.GAP
local PART_PER_UNIT = CONSTANTS.PART_PER_UNIT

local CENTER = CONSTANTS.CENTER
local EXTERIOR_RADIUS = CONSTANTS.EXTERIOR_RADIUS
local EX_OFFSET = CONSTANTS.EX_OFFSET
local G_OFFSET = CONSTANTS.G_OFFSET

local VPF = Instance.new("ViewportFrame")
VPF.Ambient = Color3.new(1, 1, 1)
VPF.LightColor = Color3.new(1, 1, 1)
VPF.LightDirection = Vector3.new(0, 0, -1)
VPF.BackgroundTransparency = 1
VPF.Size = UDim2.new(1, 0, 1, 0)

local CAMERA = Instance.new("Camera")
CAMERA.CameraType = Enum.CameraType.Scriptable
CAMERA.CFrame = CFrame.new()
CAMERA.FieldOfView = CONSTANTS.FOV
--!strict


local LocalPlayer: Player = game:GetService("Players").LocalPlayer
local RunService = game:GetService("RunService")

local fmt = string.format

local OPT_AXIS_ATTRIBUTE = "Axis"
local OPT_AXIS = "Z"
local OPT_DEGREES_ATTRIBUTE = "Degrees"
local OPT_DEGREES = 1
local OPT_MIN_DISTANCE_ATTRIBUTE = "MinDistance"
local OPT_MIN_DISTANCE = 48

local ERR_NOT_MODEL = "Rotate expects a Model, but got %q (%s)"

local Obstacle = {}

Obstacle.__index = Obstacle

function Obstacle.new(model: Model)
	assert(model:IsA("Model"), fmt(ERR_NOT_MODEL, model:GetFullName(), model.ClassName))
	
	local self = setmetatable({}, Obstacle)
	self._events = {}
	
	self._model = model
	
	self._distance = model:GetAttribute(OPT_MIN_DISTANCE_ATTRIBUTE) or
		math.max(model:GetModelSize().Magnitude * 2, OPT_MIN_DISTANCE)
	
	self._axis = model:GetAttribute(OPT_AXIS_ATTRIBUTE) or OPT_AXIS
	self._degrees = model:GetAttribute(OPT_DEGREES_ATTRIBUTE) or OPT_DEGREES
	
	-- TODO: Defer render to global handler
	table.insert(self._events, RunService.RenderStepped:Connect(function()
		self:RenderUpdate()
	end))
	
	return self
end

function Obstacle:IsLocalPlayerNearby(): boolean
	if self._distance == 0 then
		return true
	end
	
	local distance = LocalPlayer:DistanceFromCharacter(self._model:GetPrimaryPartCFrame().Position)
	return distance < self._distance
end

function Obstacle:GetRotationCFrame(): CFrame
	local degrees = math.rad(self._degrees)
	
	if self._axis == "X" then
		return CFrame.Angles(degrees, 0, 0)
	elseif self._axis == "Y" then
		return CFrame.Angles(0, degrees, 0)
	end
	
	return CFrame.Angles(0, 0, degrees)
end

function Obstacle:RenderUpdate()
	if not self:IsLocalPlayerNearby() then
		return
	end
	
	local cframe = self._model:GetPrimaryPartCFrame()
	local angles = self:GetRotationCFrame()
	
	self._model:SetPrimaryPartCFrame(cframe * angles)
end

function Obstacle:Destroy()
	for _, event: RBXScriptConnection in ipairs(self._events) do
		event:Disconnect()
	end
end

return Obstacle
-- Also set this to true if you want the thumbstick to not affect throttle, only triggers when a gamepad is conected


local onlyTriggersForThrottle = false
local ZERO_VECTOR3 = Vector3.new(0,0,0)

local betterHandlingInputStatesFlagExists, betterHandlingInputStatesFlagEnabled = pcall(function()
	return UserSettings():IsUserFeatureEnabled("UserBetterHandlingVehicleInputStates")
end)
local FFlagBetterHandlingVehicleInputStates = betterHandlingInputStatesFlagExists and betterHandlingInputStatesFlagEnabled

local AUTO_PILOT_DEFAULT_MAX_STEERING_ANGLE = 35
--[[
		___      _______                _     
	   / _ |____/ ___/ /  ___ ____ ___ (_)__ 
	  / __ /___/ /__/ _ \/ _ `(_-<(_-</ (_-<
	 /_/ |_|   \___/_//_/\_,_/___/___/_/___/
 						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.Redline)*on^2
	end
else
	local handler = car.CarSound
	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.Redline)*on^2
		handler:FireServer("updateSound","Rev",script.Rev.SoundId,pitch,script.Rev.Volume)
	end
end
-- O(n!)


local function createCurve(t, points)
	if SETTINGS.Debug == true then
		for _, point in points do
			newInstance("Part", {
				Position = point,
				Anchored = true,
				CanCollide = false,
				Size = Vector3.one,
				Color = Color3.fromRGB(0,255,0),
				Transparency = .5,
				Parent = workspace.Debris
			})
		end
	end

	-- could use recursion, but lua doesn't have optimized tail calls. 
	while #points > 1 do
		local tempPoints = points
		points = {}

		for i = 1, #tempPoints - 1 do
			local p1 = tempPoints[i]
			local p2 = tempPoints[i + 1]

			table.insert(points, lerp(p1, p2, t))
		end
	end
	
	if SETTINGS.Debug == true then
		newInstance("Part", {
			Position = points[1],
			Anchored = true,
			CanCollide = false,
			Size = Vector3.one,
			Color = Color3.fromRGB(255,0,0),
			Transparency = .5,
			Parent = workspace.Debris
		})
	end
	
	-- points[1] will contain the correct position at time 't'
	return points[1]
end

return createCurve
-- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote


local emoteNames = { wave = false, point = false, dance = true, dance2 = true, dance3 = true, laugh = false, cheer = false}

math.randomseed(tick())

function configureAnimationSet(name, fileList)
	if (animTable[name] ~= nil) then
		for _, connection in pairs(animTable[name].connections) do
			connection:disconnect()
		end
	end
	animTable[name] = {}
	animTable[name].count = 0
	animTable[name].totalWeight = 0	
	animTable[name].connections = {}

	local allowCustomAnimations = true
	local AllowDisableCustomAnimsUserFlag = false

	local success, msg = pcall(function()
		AllowDisableCustomAnimsUserFlag = UserSettings():IsUserFeatureEnabled("UserAllowDisableCustomAnims2")
	end)

	if (AllowDisableCustomAnimsUserFlag) then
		allowCustomAnimations = game:GetService("StarterPlayer").AllowCustomAnimations
	end

	-- check for config values
	local config = script:FindFirstChild(name)
	if (allowCustomAnimations and config ~= nil) then
		table.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))
		table.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))
		local idx = 1
		for _, childPart in pairs(config:GetChildren()) do
			if (childPart:IsA("Animation")) then
				table.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))
				animTable[name][idx] = {}
				animTable[name][idx].anim = childPart
				local weightObject = childPart:FindFirstChild("Weight")
				if (weightObject == nil) then
					animTable[name][idx].weight = 1
				else
					animTable[name][idx].weight = weightObject.Value
				end
				animTable[name].count = animTable[name].count + 1
				animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
				idx = idx + 1
			end
		end
	end

	-- fallback to defaults
	if (animTable[name].count <= 0) then
		for idx, anim in pairs(fileList) do
			animTable[name][idx] = {}
			animTable[name][idx].anim = Instance.new("Animation")
			animTable[name][idx].anim.Name = name
			animTable[name][idx].anim.AnimationId = anim.id
			animTable[name][idx].weight = anim.weight
			animTable[name].count = animTable[name].count + 1
			animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
-- assume we are in the character, let's check



function sepuku()
	script.Parent = nil
end

local h = script.Parent:FindFirstChild("Humanoid")

if (h == nil) then sepuku() end

local oldSpeed = h.WalkSpeed
h.WalkSpeed = 47




local torso = script.Parent:FindFirstChild("HumanoidRootPart")

if (torso == nil) then sepuku() end


local head = script.Parent:FindFirstChild("Head")
if (head == nil) then head = torso end



local s = Instance.new("Sparkles")
s.Color = Color3.new(.8, 0, .8)
s.Parent = torso


wait(7)

h.WalkSpeed = oldSpeed
s:Remove()


script.Parent = nil
--[[Brakes]]


	Tune.ABSEnabled		= true		-- Implements ABS
	Tune.ABSThreshold	= 20		-- Slip speed allowed before ABS starts working (in SPS) 

	Tune.FBrakeForce	= 30000		-- Front brake force
	Tune.RBrakeForce	= 30000		-- Rear brake force
	Tune.PBrakeForce	= 30000		-- Handbrake force
	
	Tune.FLgcyBForce	= 15000		-- Front brake force [PGS OFF]
	Tune.RLgcyBForce	= 10000		-- Rear brake force [PGS OFF]
	Tune.LgcyPBForce	= 25000		-- Handbrake force [PGS OFF]
-- Will apply a body part given the r15Folder and the r6Folder for that body part.


local function applyBodyPart(character, r15Folder, r6Folder)
    local humanoid = character:FindFirstChild("Humanoid")
    if humanoid.RigType == Enum.HumanoidRigType.R15 then
		for _, part in pairs(r15Folder:GetChildren()) do
            local oldPart = character:FindFirstChild(part.Name)
			if (oldPart) then
	            part:Clone().Parent = character
	            oldPart.Name = ""
	            oldPart:Destroy()
			end
        end
        -- Rebuild the rig
        -- Note: if applying many body parts at once it is more efficient to call this after applying them all
        buildRigFromAttachments(nil, character.HumanoidRootPart)
    else
        for _, characterMesh in pairs(r6Folder:GetChildren()) do
            local oldCharacterMesh = getOldCharacterMesh(character, characterMesh)
            if oldCharacterMesh then
                oldCharacterMesh:Destroy()
            end
            characterMesh.Parent = character
        end
    end
end

local AssetService = game:GetService("AssetService")
local InsertService = game:GetService("InsertService")

function DressCharacter(character, packageId, allowTools)
	local PackageIds = AssetService:GetAssetIdsForPackage(packageId)
	local Humanoid = character:FindFirstChild("Humanoid")
	allowTools = (allowTools or false)
	
	for _,AssetId in pairs(PackageIds) do
		local Insert = InsertService:LoadAsset(AssetId)
		
		for _,Object in pairs(Insert:GetChildren()) do
			if (Object:IsA("Folder") and Object.Name == "R15") then
				applyBodyPart(character, Object, nil)
			elseif (Object:IsA("Tool") and allowTools) then
				Humanoid:EquipTool(Object)
			elseif (Object:IsA("Accessory") or Object:IsA("Hat")) then
				Humanoid:AddAccessory(Object)
			end
		end
		
		Insert:Destroy()
	end
	
	return true
end

return DressCharacter
--[[
	SERVER PLUGINS' NAMES MUST START WITH "Server: "
	CLIENT PLUGINS' NAMES MUST START WITH "Client: "
	
	Plugins have full access to the server/client tables and most variables.
	
	You can use the MakePluginEvent to use the script instead of setting up an event.
	PlayerChatted will get chats from the custom chat and nil players. 
	PlayerJoined will fire after the player finishes initial loading
	CharacterAdded will also fire after the player is loaded, it does not use the CharacterAdded event.
	
	service.HookEvent('PlayerChatted',function(msg,plr) 
		print(msg..' from '..plr.Name..' Example Plugin')
	end)
	
	service.HookEvent('PlayerJoined',function(p) 
		print(p.Name..' Joined! Example Plugin') 
	end)
	
	service.HookEvent('CharacterAdded',function(plr) 
		server.RunCommand('name',plr.Name,'BobTest Example Plugin') 
	end)
	
--]]



server = nil -- Mutes warnings about unknown globals
service = nil
return function()
	server.Commands.ExampleCommand = {
		Prefix = server.Settings.Prefix;	-- Prefix to use for command
		Commands = {"example"};	-- Commands
		Args = {"arg1"};	-- Command arguments
		Description = "Example command";	-- Command Description
		Hidden = true; -- Is it hidden from the command list?
		Fun = false;	-- Is it fun?
		AdminLevel = "Players";	    -- Admin level; If using settings.CustomRanks set this to the custom rank name (eg. "Baristas")
		Function = function(plr,args)    -- Function to run for command
			print("HELLO WORLD FROM AN EXAMPLE COMMAND :)")
			print("Player supplied args[1] "..tostring(args[1]))
		end
	}
end