Pinkstack/roblox-luau-corpus-text huggingface dataset:
-- This function converts 4 different, redundant enumeration types to one standard so the values can be compared


function CameraUtils.ConvertCameraModeEnumToStandard( enumValue )
	
	if enumValue == Enum.TouchCameraMovementMode.Default then
		return Enum.ComputerCameraMovementMode.Follow
	end
	
	if enumValue == Enum.ComputerCameraMovementMode.Default then
		return Enum.ComputerCameraMovementMode.Classic
	end
	
	if enumValue == Enum.TouchCameraMovementMode.Classic or
		enumValue == Enum.DevTouchCameraMovementMode.Classic or
		enumValue == Enum.DevComputerCameraMovementMode.Classic or
		enumValue == Enum.ComputerCameraMovementMode.Classic then
		return Enum.ComputerCameraMovementMode.Classic
	end
	
	if enumValue == Enum.TouchCameraMovementMode.Follow or
		enumValue == Enum.DevTouchCameraMovementMode.Follow or
		enumValue == Enum.DevComputerCameraMovementMode.Follow or
		enumValue == Enum.ComputerCameraMovementMode.Follow then
		return Enum.ComputerCameraMovementMode.Follow
	end
	
	if enumValue == Enum.TouchCameraMovementMode.Orbital or
		enumValue == Enum.DevTouchCameraMovementMode.Orbital or
		enumValue == Enum.DevComputerCameraMovementMode.Orbital or
		enumValue == Enum.ComputerCameraMovementMode.Orbital then
		return Enum.ComputerCameraMovementMode.Orbital
	end
	
	-- Note: Only the Dev versions of the Enums have UserChoice as an option
	if enumValue == Enum.DevTouchCameraMovementMode.UserChoice or
		enumValue == Enum.DevComputerCameraMovementMode.UserChoice then
		return Enum.DevComputerCameraMovementMode.UserChoice
	end
	
	-- For any unmapped options return Classic camera
	return Enum.ComputerCameraMovementMode.Classic
end

return CameraUtils
-- Returns topmost ancestor in hierarchy descending from points folder


local function getTopAncestor(part)
	local prevParent = part
	local parent = part.Parent
		
	while not parent:IsA("Folder") do
		prevParent = parent
		parent = parent.Parent
	end
		
	return prevParent
end

local function getPositionRelativetoBase(part, pos)
	local basePlate = workspace:FindFirstChild("Baseplate")
	local basePosition = basePlate:GetChildren()[1].Position
	local baseSize = basePlate:GetChildren()[1].Size
	
	local posY = pos.Y
	local basePosY = basePosition.Y
	local baseSizeY = baseSize.Y
	return Vector3.new(pos.X, (basePosY + baseSizeY/2) + part.Size.Y/2, pos.Z)
end
	
local function breakModel(model)
	local children = model:GetChildren()
		
	for i,child in pairs(children) do
		-- Make part/model non-collidable
		if child:IsA("Model") then
			breakModel(child)
		elseif child:IsA("Part") then
			child.CanCollide = false
		end
	end
end
--		ndAnim:Play()


		--wait(2)
	--end

	hum.Sit = false
	if newBAV ~= nil then newBAV:remove() end
	if newBP ~= nil then newBP:remove() end
	if newBV ~= nil then newBV:remove() end

	if newBG ~= nil then newBG.cframe = CFrame.new(torsoPosition, target*Vector3.new(1,0,1) + Vector3.new(0, torsoPosition.Y, 0) ) end
	if newBG ~= nil then newBG.maxTorque = Vector3.new(newBG.P, newBG.P, newBG.P) end
	spinSound:Stop()
	wait(.25)
	if newBG ~= nil then newBG:remove() end
end


local lastKeyDown = 0
local dashTime = 0
local lastSlash = 0
local amAnimating = false
function onActivated()
	vChar = Tool.Parent
	if vChar == nil then return end
	hum = vChar:FindFirstChild("Humanoid")
	if hum == nil then return end
	--if not Tool.Enabled then return end
	if amAnimating then return end
	Tool.Enabled = false
	amAnimating = true

	torso = vChar:FindFirstChild("Torso")
	if torso == nil then Tool.Enabled = true return end

	t = r.Stepped:wait()
	if t - dashTime < .2 then
		-- dash attack
		dashIt(hum, torso)
		wait(.5)  -- reload time
		amAnimating = false
	elseif t - lastSlash < .2 then
		-- slash attack
		slashIt(hum, torso)
		--wait(1)
		amAnimating = false
		--wait(.5)  -- reload time
	else
		-- normal attack
		whackSound:Play()
		lastSlash = t
		amAnimating = false -- here must be before the wait, to allow for double-clix
		wait(.5)
	end
	if not amAnimating then Tool.Enabled = true end
end

local keyConnection = nil
function onKeyDown(key)
	if key:lower() == "w" then
		t = r.Stepped:wait()
		if (t - lastKeyDown < .2) then dashTime = t end
		lastKeyDown = t
	end
end

function onEquippedLocal(mouse)
	slashSound.Volume = 1 
	spinSound.Volume = 1
	whackSound.Volume = 1

	keyConnection = mouse.KeyDown:connect(onKeyDown)
end

function onUnequippedLocal()
	if keyConnection ~= nil then keyConnection:disconnect() end

	if newBV ~= nil then newBV:remove() end
	if newBG ~= nil then newBG:remove() end
	if newBAV ~= nil then newBAV:remove() end
	if newBP ~= nil then newBP:remove() end

	slashSound.Volume = 0
	spinSound.Volume = 0
	whackSound.Volume = 0
end

Tool.Equipped:connect(onEquippedLocal)
Tool.Unequipped:connect(onUnequippedLocal)
Tool.Activated:connect(onActivated)
--model by CatLeoYT script--



Tool = script.Parent
Handle = Tool:WaitForChild("Handle")

Players = game:GetService("Players")

Sounds = {
	CoilSound = Handle:WaitForChild("CoilSound"),
}

Gravity = 196.20
JumpHeightPercentage = 0.4

ToolEquipped = false

function GetAllConnectedParts(Object)
	local Parts = {}
	local function GetConnectedParts(Object)
		for i, v in pairs(Object:GetConnectedParts()) do
			local Ignore = false
			for ii, vv in pairs(Parts) do
				if v == vv then
					Ignore = true
				end
			end
			if not Ignore then
				table.insert(Parts, v)
				GetConnectedParts(v)
			end
		end
	end
	GetConnectedParts(Object)
	return Parts
end

function SetGravityEffect()
	if not GravityEffect or not GravityEffect.Parent then
		GravityEffect = Instance.new("BodyForce")
		GravityEffect.Name = "GravityCoilEffect"
		GravityEffect.Parent = Torso
	end
	local TotalMass = 0
	local ConnectedParts = GetAllConnectedParts(Torso)
	for i, v in pairs(ConnectedParts) do
		if v:IsA("BasePart") then
			TotalMass = (TotalMass + v:GetMass())
		end
	end
	local TotalMass = (TotalMass * 196.20 * (1 - JumpHeightPercentage))
	GravityEffect.force = Vector3.new(0, TotalMass, 0)
end

function HandleGravityEffect(Enabled)
	if not CheckIfAlive() then
		return
	end
	for i, v in pairs(Torso:GetChildren()) do
		if v:IsA("BodyForce") then
			v:Destroy()
		end
	end
	for i, v in pairs({ToolUnequipped, DescendantAdded, DescendantRemoving}) do
		if v then
			v:disconnect()
		end
	end
	if Enabled then
		CurrentlyEquipped = true
		ToolUnequipped = Tool.Unequipped:connect(function()
			CurrentlyEquipped = false
		end)
		SetGravityEffect()
		DescendantAdded = Character.DescendantAdded:connect(function()
			wait()
			if not CurrentlyEquipped or not CheckIfAlive() then
				return
			end
			SetGravityEffect()
		end)
		DescendantRemoving = Character.DescendantRemoving:connect(function()
			wait()
			if not CurrentlyEquipped or not CheckIfAlive() then
				return
			end
			SetGravityEffect()
		end)
	end
end

function CheckIfAlive()
	return (((Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0 and Torso and Torso.Parent and Player and Player.Parent) and true) or false)
end

function Equipped(Mouse)
	Character = Tool.Parent
	Humanoid = Character:FindFirstChild("Humanoid")
	Torso = Character:FindFirstChild("Torso") or Character:FindFirstChild("UpperTorso")
	Player = Players:GetPlayerFromCharacter(Character)
	if not CheckIfAlive() then
		return
	end
	if HumanoidDied then
		HumanoidDied:disconnect()
	end
	HumanoidDied = Humanoid.Died:connect(function()
		if GravityEffect and GravityEffect.Parent then
			GravityEffect:Destroy()
		end
	end)
	Sounds.CoilSound:Play()
	HandleGravityEffect(true)
	ToolEquipped = true
end

function Unequipped()
	if HumanoidDied then
		HumanoidDied:disconnect()
	end
	HandleGravityEffect(false)
	ToolEquipped = false
end

Tool.Equipped:connect(Equipped)
Tool.Unequipped:connect(Unequipped)
--[[Flip]]



function Flip()
	--Detect Orientation
	if (car.DriveSeat.CFrame*CFrame.Angles(math.pi/2,0,0)).lookVector.y > .1 or FlipDB then
		FlipWait=tick()

		--Apply Flip
	else
		if tick()-FlipWait>=3 then
			FlipDB=true
			local gyro = car.DriveSeat.Flip
			gyro.maxTorque = Vector3.new(10000,0,10000)
			gyro.P=3000
			gyro.D=500
			wait(1)
			gyro.maxTorque = Vector3.new(0,0,0)
			gyro.P=0
			gyro.D=0
			FlipDB=false
		end
	end
end
-- Update camera if it changes



workspace.Changed:connect(function (p)
	if p == "CurrentCamera" then
		camera = workspace.CurrentCamera
	end
end)


coroutine.resume(coroutine.create(function()
game:GetService("RunService").Stepped:connect(function()

	Indicator:updateAll()
game:GetService("RunService").RenderStepped:wait()
end)
end))
--[[[Default Controls]]


	--Peripheral Deadzones
	Tune.Peripherals = {
		MSteerWidth				= 67		,	-- Mouse steering control width	(0 - 100% of screen width)
		MSteerDZone				= 10		,	-- Mouse steering deadzone (0 - 100%)
		
		ControlLDZone			= 5			,	-- Controller steering L-deadzone (0 - 100%)
		ControlRDZone			= 5			,	-- Controller steering R-deadzone (0 - 100%)
	}
	
	--Control Mapping
	Tune.Controls = {
		
	--Keyboard Controls
		--Mode Toggles
		ToggleTransMode			= Enum.KeyCode.M					,
				
		--Primary Controls
		Throttle				= Enum.KeyCode.Up					,
		Brake					= Enum.KeyCode.Down					,
		SteerLeft				= Enum.KeyCode.Left					,
		SteerRight				= Enum.KeyCode.Right				,
		ToggleTCS				= Enum.KeyCode.T					,
		ToggleABS				= Enum.KeyCode.B					,
		
		--Secondary Controls
		Throttle2				= Enum.KeyCode.W					,
		Brake2					= Enum.KeyCode.S					,
		SteerLeft2				= Enum.KeyCode.A					,
		SteerRight2				= Enum.KeyCode.D					,
		
		--Manual Transmission
		ShiftUp					= Enum.KeyCode.E					,
		ShiftDown				= Enum.KeyCode.Q					,
		Clutch					= Enum.KeyCode.LeftShift			,
		
		--Handbrake
		PBrake					= Enum.KeyCode.P					,
		
	--Mouse Controls
		MouseThrottle			= Enum.UserInputType.MouseButton1	,
		MouseBrake				= Enum.UserInputType.MouseButton2	,
		MouseClutch				= Enum.KeyCode.W					,
		MouseShiftUp			= Enum.KeyCode.E					,
		MouseShiftDown			= Enum.KeyCode.Q					,
		MousePBrake				= Enum.KeyCode.LeftShift			,
		
	--Controller Mapping
		ContlrThrottle			= Enum.KeyCode.ButtonR2				,
		ContlrBrake				= Enum.KeyCode.ButtonL2				,
		ContlrSteer				= Enum.KeyCode.Thumbstick1			,
		ContlrShiftUp			= Enum.KeyCode.ButtonY				,
		ContlrShiftDown			= Enum.KeyCode.ButtonX				,
		ContlrClutch			= Enum.KeyCode.ButtonR1				,
		ContlrPBrake			= Enum.KeyCode.ButtonL1				,
		ContlrToggleTMode		= Enum.KeyCode.DPadUp				,
		ContlrToggleTCS			= Enum.KeyCode.DPadDown				,
		ContlrToggleABS			= Enum.KeyCode.DPadRight			,
	}
---////==========================================\\\---	
--Controller for: Korean Arrow Display


SignalLeft = script.InvertDirection.Value and script.Parent.Parent.Parent.ControlBox.IsOnRight or script.Parent.Parent.Parent.ControlBox.IsOnLeft
SignalRight = script.InvertDirection.Value and script.Parent.Parent.Parent.ControlBox.IsOnLeft or script.Parent.Parent.Parent.ControlBox.IsOnRight
-- ================================================================================
-- VARIABLES
-- ================================================================================
-- Services


local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local GuiService = game:GetService("GuiService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local IS_CONSOLE = GuiService:IsTenFootInterface()
local IS_MOBILE = UserInputService.TouchEnabled and not UserInputService.MouseEnabled and not IS_CONSOLE

local GAMEPAD_DEADZONE = 0.1
--[[Transmission]]


	Tune.TransModes		= {"Auto"}								--[[
	[Modes]
		"Auto"		: Automatic shifting
		"Semi"		: Clutchless manual shifting, dual clutch transmission
		"Manual"	: Manual shifting with clutch
		
		>Include within brackets
			eg: {"Semi"} or {"Auto", "Manual"}								
		>First mode is default mode													]]
	
	--Automatic Settings
	Tune.AutoShiftMode	= "RPM"												--[[
	[Modes]
		"Speed"		: Shifts based on wheel speed
		"RPM"		: Shifts based on RPM											]]	
	Tune.AutoUpThresh	= -200		--Automatic upshift point 	(relative to peak RPM, positive = Over-rev)
	Tune.AutoDownThresh = 1400		--Automatic downshift point (relative to peak RPM, positive = Under-rev)
	
	--Gear Ratios
	Tune.FinalDrive		= 4.60		 --	[TRANSMISSION CALCULATIONS FOR NERDS]
	Tune.Ratios			= {			 --		SPEED [SPS]	 = (Wheel diameter(studs) * pi(3.14) * RPM) / (60 * Gear Ratio * Final Drive * Multiplier)
		--[[Reverse]]	3.484		,--		WHEEL TORQUE = Engine Torque * Gear Ratio * Final Drive * Multiplier
		--[[Neutral]]	0			,
		--[[ 1 ]]		3.587      	,
		--[[ 2 ]]		2.022		,
		--[[ 3 ]]		1.384		,
		--[[ 4 ]]		1.000		,
		--[[ 5 ]]		0.861		,
		--[[ 6 ]]		0.621		,
	}
	Tune.FDMult			= 1.7			-- Ratio multiplier (Change this value instead of FinalDrive if car is struggling with torque ; Default = 1)
--[[Transmission]]


	Tune.TransModes		= {"Auto","Semi"}												--[[
	[Modes]
		"Auto"		: Automatic shifting
		"Semi"		: Clutchless manual shifting, dual clutch transmission
		"Manual"	: Manual shifting with clutch
		
		>Include within brackets
			eg: {"Semi"} or {"Auto", "Manual"}								
		>First mode is default mode													]]
	
	--Automatic Settings
	Tune.AutoShiftMode	= "Speed"												--[[
	[Modes]
		"Speed"		: Shifts based on wheel speed
		"RPM"		: Shifts based on RPM											]]	
	Tune.AutoUpThresh	= -3200		-- Automatic upshift point 	(relative to peak RPM, positive = Over-rev)
	Tune.AutoDownThresh = 2400		-- Automatic downshift point (relative to peak RPM, positive = Under-rev)
	Tune.ShiftTime = .05				-- The time delay in which you initiate a shift and the car changes gear
	
	--Gear Ratios
	Tune.FinalDrive		= 2.9
	Tune.Ratios			= {
		--[[Reverse]]	4.29			,
		--[[Neutral]]	0			,
		--[[ 1 ]]		4.71			,
		--[[ 2 ]]		3.14		,
		--[[ 3 ]]		2.10		,
		--[[ 4 ]]		1.67		,
		--[[ 5 ]]		1.29		,
		--[[ 6 ]]		1.00			,
		--[[ 7 ]]		0.84			,
	}
	Tune.FDMult			= 1.00			-- Ratio multiplier (Change this value instead of FinalDrive if car is struggling with torque ; Default = 1)
--					if GetHitPlayers() >= 3 then
--						AwardBadge:Invoke(FiredPlayer,"Explosive Results")
--					end


						
					local FiredPlayer = ReflectedPlayer or FiredPlayer
					local DoDamage = PlayerDamager:CanDamageHumanoid(FiredPlayer,HitHumanoid)
					if DoDamage then
						local DamageFraction = 0
						if RadiusFromBlast < BLAST_RADIUS/2 then
							DamageFraction = 1
						elseif RadiusFromBlast < BLAST_RADIUS then
							DamageFraction = 1 - (RadiusFromBlast - BLAST_RADIUS/2)/(BLAST_RADIUS/2)
						end

						if HitPlayer == FiredPlayer and DamageFraction == 1 then
							HitHumanoid.Health = 0
						else
							PlayerDamager:DamageHumanoid(FiredPlayer,HitHumanoid,50 + (DamageFraction * 50),DamageName)
						end
					end
				end
			end		
			
			--Break joints if it isn't a character.
			if BreakJoints then
				ExplosionTouchPart:BreakJoints()
			end
			
			--If the part is able to fade with explosions, signal it to fade.
--[[
	This is a simple signal implementation that has a dead-simple API.

		local signal = createSignal()

		local disconnect = signal:subscribe(function(foo)
			print("Cool foo:", foo)
		end)

		signal:fire("something")

		disconnect()
]]



local function addToMap(map, addKey, addValue)
	local new = {}

	for key, value in pairs(map) do
		new[key] = value
	end

	new[addKey] = addValue

	return new
end

local function removeFromMap(map, removeKey)
	local new = {}

	for key, value in pairs(map) do
		if key ~= removeKey then
			new[key] = value
		end
	end

	return new
end

local function createSignal()
	local connections = {}

	local function subscribe(_, callback)
		assert(typeof(callback) == "function", "Can only subscribe to signals with a function.")

		local connection = {
			callback = callback,
		}

		connections = addToMap(connections, callback, connection)

		local function disconnect()
			assert(not connection.disconnected, "Listeners can only be disconnected once.")

			connection.disconnected = true
			connections = removeFromMap(connections, callback)
		end

		return disconnect
	end

	local function fire(_, ...)
		for callback, connection in pairs(connections) do
			if not connection.disconnected then
				callback(...)
			end
		end
	end

	return {
		subscribe = subscribe,
		fire = fire,
	}
end

return createSignal
--brownUI = Color3.fromRGB(230, 191, 157),


essenceYellow = Color3.fromRGB(255, 255, 111),

badRed = Color3.fromRGB(255, 0, 0),
fadedBadRed = Color3.fromRGB(129, 0, 0),
uncooked = Color3.fromRGB(195, 116, 116),

goodGreen = Color3.fromRGB(170, 255, 0),
fadedGoodGreen = Color3.fromRGB(106, 129, 58),

grey200 = Color3.fromRGB(200,200,200),
ironGrey = Color3.fromRGB(200, 190, 181),

steel = Color3.fromRGB(106, 97, 84),

mojoPurp = Color3.fromRGB(222, 147, 223)

}

return module
-- It's important we update all icons when a players language changes to account for changes in the width of text, etc


task.spawn(function()
	local LocalizationService = game:GetService("LocalizationService")
	local success, translator = pcall(function() return LocalizationService:GetTranslatorForPlayerAsync(localPlayer) end)
	local function updateAllIcons()
		local icons = IconController.getIcons()
		for _, icon in pairs(icons) do
			icon:_updateAll()
		end
	end
	if success then
		translator:GetPropertyChangedSignal("LocaleId"):Connect(updateAllIcons)
		task.delay(1, updateAllIcons)
		task.delay(10, updateAllIcons)
	end
end)


return IconController
--Check moderation data


game.Players.PlayerAdded:Connect(function(plr)
	
	--Kick new players if game is shutting down
	if shuttingDown then
		plr:Kick("This server has shut down.")
	end
	
	--Kick banned players, or remove ban data if ban time is over
	local banSuccess, banData = pcall(function()
		local data = ds:GetAsync(plr.UserId .. "Banned")
		return data
	end)
	
	if banSuccess and banData then
		local banEnd = banData[1]
		
		if os.time() >= banEnd then
			pcall(function()
				ds:RemoveAsync(plr.UserId .. "Banned")
			end)
			
		else
			local banReason = banData[2]
			
			local dateInfo = os.date("!*t", banEnd)
			local dateFormatted = dateInfo["day"] .. "/" .. dateInfo["month"] .. "/" .. dateInfo["year"] .. "  " .. dateInfo["hour"] .. ":" .. dateInfo["min"] .. ":" .. dateInfo["sec"]
			local banMessage = "Banned for: " .. banReason .. " | Ends: " .. dateFormatted
			
			plr:Kick(banMessage)
		end
	end
	
	--Mute players or unmute them if mute time is over
	local muteSuccess, muteData = pcall(function()
		local data = ds:GetAsync(plr.UserId .. "Muted")
		return data
	end)
	
	if muteSuccess and muteData then
		local muteEnd = muteData[1]
		
		if os.time() >= muteEnd then
			pcall(function()
				ds:RemoveAsync(plr.UserId .. "Muted")
			end)
			
		else
			channel:MuteSpeaker(plr.Name)
			
			local timeToUnmute = muteEnd - os.time()
			task.wait(timeToUnmute)
			
			if plr then
				channel:UnmuteSpeaker(plr.Name)
			end
		end
	end
end)
----- hot tap handler -----



hotTap.Interactive.ClickDetector.MouseClick:Connect(function()
	if hotOn.Value == false then
		hotOn.Value = true
		faucet.ParticleEmitter.Enabled = true
		waterSound:Play()
		hotTap:SetPrimaryPartCFrame(hotTap.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(45), 0))
	else
		hotOn.Value = false
		if coldOn.Value == false then
			faucet.ParticleEmitter.Enabled = false
			waterSound:Stop()
		end
		hotTap:SetPrimaryPartCFrame(hotTap.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(-45), 0))
	end
end)
--[[
	ETC
]]


local random = Random.new()
local EventData = ReplicatedStorage.Events.EventData
EventData.OnServerEvent:Connect(function(player, cmd, ...)
	if cmd == "SpectatePlayer" then
		local playerToSpectate = ...
		if not Util.playerIsAlive(player) and Util.playerIsAlive(playerToSpectate) then
			player.ReplicationFocus = playerToSpectate.Character.Head
		end
	end
end)

local RespawnEvent = ReplicatedStorage.Events.RespawnEvent
RespawnEvent.Event:Connect(function(player)
	if gameStageHandler.currentStageClassName == "Gameplay" and player and player.Character then
		wait(Conf.respawnTime)
		if not Util.playerIsAlive(player) then
			-- Save all player's weapon names to give them new instances of them when they respawn
			local toolNamesBeforeDeath = {}
			for _, instance in pairs(player.Backpack:GetChildren()) do
				if instance:IsA("Tool") and ReplicatedStorage.Assets.Weapons:FindFirstChild(instance.Name) then
					table.insert(toolNamesBeforeDeath, instance.Name)
				end
			end

			local characterAddedConn = nil
			characterAddedConn = player.CharacterAdded:Connect(function(character)
				characterAddedConn:Disconnect()

				-- Wait a frame for the character to initialize/spawn
				RunService.Heartbeat:Wait()

				-- Add weapons the player had before dying to their backpack
				for _, weaponName in ipairs(toolNamesBeforeDeath) do
					local weaponTemplate = ReplicatedStorage.Assets.Weapons:FindFirstChild(weaponName)
					if weaponTemplate ~= nil then
						weaponTemplate:Clone().Parent = player.Backpack
					end
				end

				-- Set up the player's character when they respawn
				local head = character:WaitForChild("Head")
				-- Calculate where to spawn player based on storm's current target position/radius
				local targetPos, targetRadius = ShrinkingBarrier.getNextPositionAndRadius()
				local randomRadius = targetRadius * random:NextNumber(Conf.respawn_radius_lowest_fraction, Conf.respawn_radius_highest_fraction)
				local randomRadians = random:NextNumber(0, 2 * math.pi)
				if Conf.num_teams == 2 then
					-- In team mode, make players spawn only on their team's half of the map
					local dividingAngle = ShrinkingBarrier.getDividingAngle()
					if PlayerMatchInfo.GetField(player, "teamNumber") == 1 then
						randomRadians = random:NextNumber(dividingAngle - math.pi, dividingAngle)
					else
						randomRadians = random:NextNumber(dividingAngle, dividingAngle + math.pi)
					end
				end
				local xSpawn = targetPos.X + randomRadius * math.cos(randomRadians)
				local ySpawn = targetPos.Y + Conf.respawn_height_fraction * Conf.delivery_vehicle_spawn_height
				local zSpawn = targetPos.Z + randomRadius * math.sin(randomRadians)
				head.CFrame = CFrame.new(xSpawn, ySpawn, zSpawn)
				player.ReplicationFocus = head
			end)
			Util.loadCharacter(player)
		end
	end
end)

if not PingHandler.doingSetup and not PingHandler.didSetup then
	PingHandler.setup()
end
-- connect events



Humanoid.Died:connect(onDied)
Humanoid.Running:connect(onRunning)
Humanoid.Jumping:connect(onJumping)
Humanoid.Climbing:connect(onClimbing)
Humanoid.GettingUp:connect(onGettingUp)
Humanoid.FreeFalling:connect(onFreeFall)
Humanoid.FallingDown:connect(onFallingDown)
Humanoid.Seated:connect(onSeated)
Humanoid.PlatformStanding:connect(onPlatformStanding)
Humanoid.Swimming:connect(onSwimming)
--returns the wielding player of this tool


function getPlayer()
	local char = Tool.Parent
	return game:GetService("Players"):GetPlayerFromCharacter(Character)
end

function Toss(direction)
	local handlePos = Vector3.new(Tool.Handle.Position.X, 0, Tool.Handle.Position.Z)
	local spawnPos = Character.Head.Position
	spawnPos  = spawnPos + (direction * 5)
	Tool.Handle.Transparency = 1

	local Object = Tool.Handle:Clone()
	Object.Parent = workspace
	Object.Transparency = 0
	Object.CanCollide = true
	Object.Server.Disabled = false
	Object.Stabilize.Disabled = false
	Object.Interface.Enabled = true

	Object.CFrame = Tool.Handle.CFrame
	Object.Velocity = (direction*AttackVelocity) + Vector3.new(0,AttackVelocity/7.5,0)
	local rand = 11.25
	Object.RotVelocity = Vector3.new(math.random(-rand,rand),math.random(-rand,rand),math.random(-rand,rand))
	Object:SetNetworkOwner(getPlayer())

	local tag = Instance.new("ObjectValue")
	tag.Value = getPlayer()
	tag.Name = "creator"
	tag.Parent = Object
	Tool:Destroy()
end


script.Parent.Power.OnServerEvent:Connect(function(player, Power)
	AttackVelocity = Power
end)

Remote.OnServerEvent:Connect(function(player, mousePosition)
	if not AttackAble then return end
	AttackAble = false
	if Humanoid and Humanoid.RigType == Enum.HumanoidRigType.R15 then
		Remote:FireClient(getPlayer(), "PlayAnimation", "Animation")
	end
	local targetPos = mousePosition.p
	local lookAt = (targetPos - Character.Head.Position).unit
	Toss(lookAt)
	LeftDown = true
end)

function onLeftUp()
	LeftDown = false
end

Tool.Equipped:Connect(function()
	Character = Tool.Parent
	Humanoid = Character:FindFirstChildOfClass("Humanoid")
end)

Tool.Unequipped:Connect(function()
	Character = nil
	Humanoid = nil
end)