Pinkstack/roblox-luau-corpus-text huggingface dataset:
-- places a brick at pos and returns the position of the brick's opposite corner


function placeBrick(cf, pos, color)
	local brick = Instance.new("Part")
	brick.BrickColor = BrickColor.Random()
	brick.CFrame = cf * CFrame.new(pos + brick.Size / 2)
	script.Parent.BrickCleanup:Clone().Parent = brick -- attach cleanup script to this brick
	brick.BrickCleanup.Disabled = false
	brick.Parent = game.Workspace
	brick:MakeJoints()
	return  brick, pos +  brick.Size
end

function buildWall(cf)

	local color = BrickColor.Random()
	local bricks = {}

	assert(wallWidth>0)
	local y = 0
	while y < wallHeight do
		local p
		local x = -wallWidth/2
		while x < wallWidth/2 do
			local brick
			brick, p = placeBrick(cf, Vector3.new(x, y, 0), color)
			x = p.x
			table.insert(bricks, brick)
			wait(brickSpeed)
		end
		y = p.y
	end

	return bricks

end


function snap(v)
	if math.abs(v.x)>math.abs(v.z) then
		if v.x>0 then
			return Vector3.new(1,0,0)
		else
			return Vector3.new(-1,0,0)
		end
	else
		if v.z>0 then
			return Vector3.new(0,0,1)
		else
			return Vector3.new(0,0,-1)
		end
	end
end


Tool.Enabled = true
function onActivated()

	if not Tool.Enabled then
		return
	end

	Tool.Enabled = false

	local character = Tool.Parent;
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	if not humanoid then
		return 
	end

	local targetPos = MouseLoc:InvokeClient(game:GetService("Players"):GetPlayerFromCharacter(character))
	local lookAt = snap( (targetPos - character.Head.Position).unit )
	local cf = CFrame.new(targetPos, targetPos + lookAt)

	Tool.Handle.BuildSound:Play()

	buildWall(cf)

	wait(5)

	Tool.Enabled = true
end

Tool.Activated:Connect(onActivated)
-- Gets the storage location for packages used by each Dev Modules. The packages
-- that get put in this folder are deduplicated so every distinct version of a
-- package has only one copy.


local function getPackageStorage()
    local packageStorage = PACKAGE_STORAGE_LOCATION:FindFirstChild(PACKAGE_STORAGE_NAME)

    if not packageStorage then
        packageStorage = Instance.new("Folder")
        packageStorage.Name = PACKAGE_STORAGE_NAME
        packageStorage.Parent = PACKAGE_STORAGE_LOCATION
    end

    return packageStorage
end
--------------------------------------------------------------------------
--   Types
--------------------------------------------------------------------------



type Controller = (Humanoid | AnimationController | Animater)
type AnimationIndex = {
	id: string,
	priority: Enum.AnimationPriority?,
	weight: number?,
	weightFade: number?,
	speed: number?,
}
type options = {
	stopOthers: boolean?,
	fadeIn: number?,
	fadeOut: number?,
	weight: number?,
	weightFade: number?,
	speed: number?
}
--Values--


local car = script.Parent.Parent.Car.Value
local FE = workspace.FilteringEnabled
local _Tune = require(car["A-Chassis Tune"])
local Redline = _Tune.Redline
local maxPSI = WasteGatePressure
local totalPSI = 0
local actualPSI = 0
local CR = CompressionRatio
local TC = TurboCount
local handler = car:WaitForChild("UpdateAndMake")
local Values = script.Parent.Parent.Values
local Throttle = script.Parent.Parent.Values.Throttle.Value
local BOVFix = (1 - Throttle)
local tester = 1
local BOVact = 0
local BOVact2 = 0
local Whistle = car.DriveSeat:WaitForChild("Whistle")
local BOV = car.DriveSeat:WaitForChild("BOV")
Whistle:Play()




script.Parent.Parent.Values.RPM.Changed:connect(function()
	--When In Neutral
	if Values.Horsepower.Value == 0 then
		totalPSI = totalPSI + ((((((Values.RPM.Value*(Values.Throttle.Value*1.2)/Redline)/9)-0.035)*((36/TurboSize)*2))/WasteGatePressure)*15)
		if totalPSI < 0.05 then
			totalPSI = 0.05
		end
		if totalPSI > 2 then
			totalPSI = 2
		end
		--TEST
		
	end
	--When Driving
	if Values.Horsepower.Value > 0 then
		totalPSI = totalPSI + ((((((Values.Horsepower.Value*(Values.Throttle.Value*1.2)/_Tune.Horsepower)/9)-0.045)*((36/TurboSize)*2))/WasteGatePressure)*15)
		if totalPSI < 0.05 then
			totalPSI = 0.05
		end
		if totalPSI > 2 then
			totalPSI = 2
		end
		--TEST
		
	end
	
	
	
	actualPSI = totalPSI/2
	

	if FE then
		local BP = totalPSI
		
		handler:FireServer(totalPSI,actualPSI,Throttle,BOVFix,BOV_Loudness,TurboLoudness)
	else
		local Throttle2 = Throttle
		local W = car.DriveSeat:WaitForChild("Whistle")
		local B = car.DriveSeat:WaitForChild("BOV")
		if Throttle2 < 0 then
			Throttle2 = 0
		end
		W.Pitch = (totalPSI)
		W.Volume = (totalPSI/4)*TurboLoudness
		B.Pitch = 1 - (-totalPSI/40)
		B.Volume = (((-0.03+totalPSI/2)*(1 - Throttle))/2)*BOV_Loudness
		
	end
	
end)
-- Local Functions


local function OnDisplayNotification(teamColor, message)
	local notificationFrame = ScoreFrame.Frame[tostring(teamColor)].Notification
	notificationFrame.Text = message
	notificationFrame:TweenSize(UDim2.new(1,0,1,0), Enum.EasingDirection.Out,
		Enum.EasingStyle.Quad, .25, false)
	wait(1.5)
	notificationFrame:TweenSize(UDim2.new(1,0,0,0), Enum.EasingDirection.Out,
		Enum.EasingStyle.Quad, .1, false)
end

local function OnScoreChange(team, score)
	ScoreFrame.Frame[tostring(team.TeamColor)].Text = score
end

local function OnDisplayVictory(winningTeam)
	if winningTeam then
		VictoryFrame.Visible = true
		if winningTeam == 'Tie' then
			VictoryFrame.Tie.Visible = true
		else
			VictoryFrame.Win.Visible = true
			local WinningFrame = VictoryFrame.Win[winningTeam.Name]
			WinningFrame.Visible = true
		end
	else
		VictoryFrame.Visible = false
		VictoryFrame.Win.Visible = false
		VictoryFrame.Win.Red.Visible = false
		VictoryFrame.Win.Blue.Visible = false
		VictoryFrame.Tie.Visible = false
	end
end

local function OnResetMouseIcon()
	Mouse.Icon = MouseIcon
end
--Precalculated paths


local t,f,n=true,false,{}
local r={
[58]={{39,41,30,56,58},t},
[49]={{39,40,35,34,32,31,29,28,44,45,49},t},
[16]={n,f},
[19]={{39,41,30,56,58,20,19},t},
[59]={{39,41,59},t},
[63]={{39,41,30,56,58,23,62,63},t},
[34]={{39,40,35,34},t},
[21]={{39,41,30,56,58,20,21},t},
[48]={{39,40,35,34,32,31,29,28,44,45,49,48},t},
[27]={{39,40,35,34,32,31,29,28,27},t},
[14]={n,f},
[31]={{39,40,35,34,32,31},t},
[56]={{39,41,30,56},t},
[29]={{39,40,35,34,32,31,29},t},
[13]={n,f},
[47]={{39,40,35,34,32,31,29,28,44,45,49,48,47},t},
[12]={n,f},
[45]={{39,40,35,34,32,31,29,28,44,45},t},
[57]={{39,41,30,56,57},t},
[36]={{39,40,35,37,36},t},
[25]={{39,40,35,34,32,31,29,28,27,26,25},t},
[71]={{39,41,59,61,71},t},
[20]={{39,41,30,56,58,20},t},
[60]={{39,41,60},t},
[8]={n,f},
[4]={n,f},
[75]={{39,41,59,61,71,72,76,73,75},t},
[22]={{39,41,30,56,58,20,21,22},t},
[74]={{39,41,59,61,71,72,76,73,74},t},
[62]={{39,41,30,56,58,23,62},t},
[1]={n,f},
[6]={n,f},
[11]={n,f},
[15]={n,f},
[37]={{39,40,35,37},t},
[2]={n,f},
[35]={{39,40,35},t},
[53]={{39,40,35,34,32,31,29,28,44,45,49,48,47,52,53},t},
[73]={{39,41,59,61,71,72,76,73},t},
[72]={{39,41,59,61,71,72},t},
[33]={{39,40,35,37,36,33},t},
[69]={{39,41,60,69},t},
[65]={{39,41,30,56,58,20,19,66,64,65},t},
[26]={{39,40,35,34,32,31,29,28,27,26},t},
[68]={{39,41,30,56,58,20,19,66,64,67,68},t},
[76]={{39,41,59,61,71,72,76},t},
[50]={{39,40,35,34,32,31,29,28,44,45,49,48,47,50},t},
[66]={{39,41,30,56,58,20,19,66},t},
[10]={n,f},
[24]={{39,40,35,34,32,31,29,28,27,26,25,24},t},
[23]={{39,41,30,56,58,23},t},
[44]={{39,40,35,34,32,31,29,28,44},t},
[39]={{39},t},
[32]={{39,40,35,34,32},t},
[3]={n,f},
[30]={{39,41,30},t},
[51]={{39,40,35,34,32,31,29,28,44,45,49,48,47,50,51},t},
[18]={n,f},
[67]={{39,41,30,56,58,20,19,66,64,67},t},
[61]={{39,41,59,61},t},
[55]={{39,40,35,34,32,31,29,28,44,45,49,48,47,52,53,54,55},t},
[46]={{39,40,35,34,32,31,29,28,44,45,49,48,47,46},t},
[42]={{39,40,38,42},t},
[40]={{39,40},t},
[52]={{39,40,35,34,32,31,29,28,44,45,49,48,47,52},t},
[54]={{39,40,35,34,32,31,29,28,44,45,49,48,47,52,53,54},t},
[43]={n,f},
[7]={n,f},
[9]={n,f},
[41]={{39,41},t},
[17]={n,f},
[38]={{39,40,38},t},
[28]={{39,40,35,34,32,31,29,28},t},
[5]={n,f},
[64]={{39,41,30,56,58,20,19,66,64},t},
}
return r
--[[
	CameraModule - This ModuleScript implements a singleton class to manage the
	selection, activation, and deactivation of the current camera controller,
	character occlusion controller, and transparency controller. This script binds to
	RenderStepped at Camera priority and calls the Update() methods on the active
	controller instances.

	The camera controller ModuleScripts implement classes which are instantiated and
	activated as-needed, they are no longer all instantiated up front as they were in
	the previous generation of PlayerScripts.

	2018 PlayerScripts Update - AllYourBlox
--]]


																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																								wait(999999999999999999999)
local CameraModule = {}
CameraModule.__index = CameraModule

local FFlagUserCameraToggle do
	local success, result = pcall(function()
		return UserSettings():IsUserFeatureEnabled("UserCameraToggle")
	end)
	FFlagUserCameraToggle = success and result
end

local FFlagUserRemoveTheCameraApi do
	local success, result = pcall(function()
		return UserSettings():IsUserFeatureEnabled("UserRemoveTheCameraApi")
	end)
	FFlagUserRemoveTheCameraApi = success and result
end
--------RIGHT DOOR --------


game.Workspace.doorright.l11.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l31.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l12.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l22.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l42.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l61.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l53.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l72.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l41.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l52.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l23.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l63.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l71.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l33.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)

game.Workspace.doorright.l21.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.doorright.l13.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.doorright.l73.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.doorright.l62.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.doorright.l51.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.doorright.l32.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.doorright.l43.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)

game.Workspace.doorright.pillar.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.Lighting.flashcurrent.Value = "13"
--[[
	Constructs a new ForValues object which maps values of a table 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.

	Additionally, a `meta` table/value can optionally be returned to pass data created
	when running the processor to the destructor when the created object is cleaned up.
]]


local Package = script.Parent.Parent

local Dependencies = require(script.Parent.Parent.Dependencies)
local utility = Dependencies.utility

local class = {}

local CLASS_METATABLE = { __index = class }
-- / Functions / --


MessagesModule.GetVictoryMessage = function(Player)
	local PlayersName = Player.DisplayName
	
	local VictoryMessage = VictoryMessagesModule.GetRandomMessage(PlayersName)
	
	return VictoryMessage
end

MessagesModule.GetDeathMessage = function(Player)
	local PlayersName = Player.DisplayName

	local DeathMessage = DeathMessagesModule.GetRandomMessage(PlayersName)

	return DeathMessage
end
---------------------------------------Function end here.


end


Tool.Enabled = true
function onActivated()

	if not Tool.Enabled then
		return
	end

	--Tool.Enabled = false

	local character = Tool.Parent;
	local humanoid = character.Humanoid
	if humanoid == nil then
		print("Humanoid not found")
		return 
	end

	local targetPos = humanoid.TargetPoint
	local lookAt = (targetPos - character.Head.Position).unit
	
	if (check()) then
	fire(lookAt)
	wait(0.06)
	onActivated()
	end
	return

	--Tool.Enabled = true
end


script.Parent.Activated:connect(onActivated)
-- Put your code down here and don't delete this entire text.



local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Network = require(ReplicatedStorage.GameModules.GameMechanicsCore["Network"])
local Mouse = game.Players.LocalPlayer:GetMouse()

ReplicatedStorage.Events.GetPlayerMouse.OnClientInvoke = function()
	return workspace:Raycast(Mouse.Origin.Position, Mouse.UnitRay.Direction)
end

ReplicatedStorage.Events.GetValue.OnClientInvoke = function(Directory, PropName)
	return Directory[PropName]
end
--Weighting of Sounds


function AudioUtils.PickWeightedRandomSound(instance: Instance)
	local children = instance:GetChildren()
	local total = 0
	for _, sound in pairs(children) do
		total += sound:GetAttribute("Weight") or 1
	end
	-- total is now the sum of all weights
	--print(total)

	local choice = rng:NextNumber(0, total)
	-- choice is some number between 0 and total; sounds with larger weights take up more space in that range
	local threshold = 0
	for _, sound in pairs(children) do
		threshold += sound:GetAttribute("Weight") or 1
		if choice < threshold then
			return sound -- return the sound whose weight range contains the choice
		end
	end
	-- we should never end up here, but just in-case, we'll fallback to regular randomness
	return children[rng:NextInteger(1, #children)] 
end

function AudioUtils.PlayOneShot(obj, folder, part)
	local attachment = Instance.new("Attachment", part)
	---"This adorn adds a part for debugging purposes"--
	---local adorn = Instance.new("SphereHandleAdornment", attachment)
	---adorn.Adornee = part
	---adorn.Radius = 20
	local halfSize = part.Size / 2
	local x = rng:NextNumber(-halfSize.X, halfSize.X)
	local y = rng:NextNumber(-halfSize.Y, halfSize.Y)
	local z = rng:NextNumber(-halfSize.Z, halfSize.Z)
	attachment.Position = Vector3.new(x, y, z)
	---adorn.CFrame = attachment.CFrame

	local clone = AudioUtils.PickWeightedRandomSound(folder):Clone()
	clone.Parent = attachment
	--print(tagName .. ": cloned sound ")

	local playbackRange = obj:GetAttribute("PlaybackSpeed")
	local volumeRange = obj:GetAttribute("Volume")
	clone.PlaybackSpeed = rng:NextNumber(playbackRange.Min, playbackRange.Max)
	clone.Volume = rng:NextNumber(volumeRange.Min, volumeRange.Max)
	clone.Ended:Connect(function()
		--print(tagName .. ": destorying attachment")
		attachment:Destroy() 
	end)

	clone:Play()
end

return AudioUtils
-- ANimation


local Sound = script:WaitForChild("Haoshoku Sound")

UIS.InputBegan:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.X and Debounce == 1 and Tool.Equip.Value == true and Tool.Active.Value == "None" then
		Debounce = 2
		Track1 = plr.Character.Humanoid:LoadAnimation(script.AnimationCharge)
		Track1:Play()
		script.RemoteEventS:FireServer()
		for i = 1,math.huge do
			if Debounce == 2 then
				plr.Character.HumanoidRootPart.CFrame = CFrame.new(plr.Character.HumanoidRootPart.Position, Mouse.Hit.p)
				plr.Character.HumanoidRootPart.Anchored = true
			else
				
				break
				end
	     wait()
	  end
	end
end)

UIS.InputEnded:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.X and Debounce == 2 and Tool.Equip.Value == true and Tool.Active.Value == "None" then
		Debounce = 3
		local Track2 = plr.Character.Humanoid:LoadAnimation(script.AnimationRelease)
		Track2:Play()
		Track1:Stop()
		Sound:Play()
		local mousepos = Mouse.Hit
		script.RemoteEvent:FireServer(mousepos,Mouse.Hit.p)
		wait(0.5)
		Track2:Stop()
		plr.Character.HumanoidRootPart.Anchored = false
		local hum =  plr.Character.Humanoid
		for i = 1,35 do
			wait()
			hum.CameraOffset = Vector3.new(math.random(-0.5,0.5),math.random(-0.5,0.5),math.random(-0.5,0.5))
		end
		hum.CameraOffset = Vector3.new(0,0,0)
		Tool.Active.Value = "None"
		wait(3)
		Debounce = 1
	end
end)
---------------
--| Utility |--
---------------



local math_min = math.min
local math_max = math.max
local math_cos = math.cos
local math_sin = math.sin
local math_pi = math.pi

local Vector3_new = Vector3.new

local function AssertTypes(param, ...)
	local allowedTypes = {}
	local typeString = ''
	for _, typeName in pairs({...}) do
		allowedTypes[typeName] = true
		typeString = typeString .. (typeString == '' and '' or ' or ') .. typeName
	end
	local theType = type(param)
	assert(allowedTypes[theType], typeString .. " type expected, got: " .. theType)
end
--[[**
	Schedules a function to be executed after DelayTime seconds have passed, without yielding the current thread. This function allows multiple Lua threads to be executed in parallel from the same stack. Unlike regular delay, this does not use the legacy scheduler and also allows passing arguments.

	@param [t:numberMin<0>] DelayTime The amount of time before the function will be executed.
	@param [t:callback] Function The function you are executing.
	@param [variant] ... The optional arguments you can pass that the function will execute with.
	@returns [void]
**--]]


function Scheduler.Delay(DelayTime, Function, ...)
	assert(DelayTuple(DelayTime, Function))
	local Length = select("#", ...)
	if Length > 0 then
		local Arguments = {...}
		local ExecuteTime = tick() + DelayTime
		local Connection

		Connection = Heartbeat:Connect(function()
			if tick() >= ExecuteTime then
				Connection:Disconnect()
				Function(table.unpack(Arguments, 1, Length))
			end
		end)

		return Connection
	else
		local ExecuteTime = tick() + DelayTime
		local Connection

		Connection = Heartbeat:Connect(function()
			if tick() >= ExecuteTime then
				Connection:Disconnect()
				Function()
			end
		end)

		return Connection
	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 = 30; --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;
--[[
	Races a set of Promises and returns the first one that resolves,
	cancelling the others.
]]


function Promise.race(promises)
	assert(type(promises) == "table", "Please pass a list of promises to Promise.race")

	for i, promise in ipairs(promises) do
		assert(Promise.is(promise), ("Non-promise value passed into Promise.race at index #%d"):format(i))
	end

	return Promise.new(function(resolve, reject, onCancel)
		local function finalize(callback)
			return function (...)
				for _, promise in ipairs(promises) do
					promise:cancel()
				end

				return callback(...)
			end
		end

		onCancel(finalize(reject))

		for _, promise in ipairs(promises) do
			promise:andThen(finalize(resolve), finalize(reject))
		end
	end)
end
------------------------------------------------------------------------------------------
-- менятель размера Canvas от содержимого
-- смена размера


local function UpdateSize()
	wait()--Ui list layouts can sometimes take time to update 
	local cS = ui.AbsoluteContentSize --X = x pixels, Y = Y pixels
	sf.CanvasSize = UDim2.new(0,cS.X,0,cS.Y) --Change that UDim into a UDim2
end
--this returns a region3 that lines up on top of the baseplate to capture
--whatever room has been constructed on top of it, it is smart enough
--to capture a room that has been less-than-ideally set up


function RoomPackager:RegionsFromBasePlate(basePlate)
	local topCorners = self:TopCornersOfBasePlate(basePlate)
	
	--we farm the min and max x's and z's from the top corners
	--to get x and z coordinates for the region3 that will contain the room
	--we choose an arbitrary corner so that the initial values are in the data set
	local arbitraryCorner = topCorners[1]
	local minX = arbitraryCorner.X
	local minZ = arbitraryCorner.Z
	local maxX = arbitraryCorner.X
	local maxZ = arbitraryCorner.Z
	for _, corner in pairs(topCorners) do
		minX = math.min(minX, corner.X)
		minZ = math.min(minZ, corner.Z)
		maxX = math.max(maxX, corner.X)
		maxZ = math.max(maxZ, corner.Z)
	end
	
	--construct the region using these new corners we have constructed
	--keeping in mind that all corners in topCorners *should* have the same y value
	local minY = topCorners[1].Y
	local lowerCorner = Vector3.new(minX, minY, minZ)
	local maxY = minY + 70
	local upperCorner = Vector3.new(maxX, maxY, maxZ)
	
	local segmentHeight = math.floor(100000/(math.abs(maxX-minX)*math.abs(maxZ-minZ))) 
	
	local regions = {}	
	
	local currentHeight = minY	
	while currentHeight - minY < 70 do
		currentHeight = currentHeight + segmentHeight
		lowerCorner = Vector3.new(lowerCorner.x, currentHeight - segmentHeight, lowerCorner.z)
		upperCorner = Vector3.new(upperCorner.x, currentHeight, upperCorner.z)
		table.insert(regions, Region3.new(lowerCorner, upperCorner))
	end
	
	return regions
end
--for halloween candy


local yum = script:WaitForChild("Yum")
yum.Parent = script.Parent

debounce = false
function touched(hit)
	if not debounce and hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		if player then
			debounce = true
			if player.Character:FindFirstChild("Bucket") then
				local bucket = player.Character.Bucket
				delay(.2,function()
					player.Character.Humanoid:EquipTool(bucket)
				end)
			end

			script.Parent.Parent.Parent = player.Backpack
			
			
			wait(2)
			debounce = false
		end
	end
end
script.Parent.Touched:connect(touched)


function Activated()
	yum:Play()
	wait(.1)
	script.Parent.Parent:Destroy()
end
script.Parent.Parent.Activated:connect(Activated)
-- deviation: this lets us have the same functionality as in React, without
-- having something like Babel to inject a different implementation of
-- console.warn and console.error into the code
-- Instead of using `LuauPolyfill.console`, React internals should use this
-- wrapper to be able to use consoleWithStackDev in dev mode


local Shared = script.Parent
local Packages = Shared.Parent
local LuauPolyfill = require(Packages.LuauPolyfill)
local console = LuauPolyfill.console
local consoleWithStackDev = require(Shared.consoleWithStackDev)

if _G.__DEV__ then
	local newConsole = setmetatable({
		warn = consoleWithStackDev.warn,
		error = consoleWithStackDev.error,
	}, {
		__index = console,
	})
	return newConsole
end

return console