Pinkstack/roblox-luau-corpus-text huggingface dataset:
--Remove with FFlagPlayerScriptsBindAtPriority


function BaseCamera:OnKeyUp(input, processed)
	if input.KeyCode == Enum.KeyCode.Left then
		self.turningLeft = false
	elseif input.KeyCode == Enum.KeyCode.Right then
		self.turningRight = false
	end
end

function BaseCamera:UpdateMouseBehavior()
	-- first time transition to first person mode or mouse-locked third person
	if self.inFirstPerson or self.inMouseLockedMode then
		UserGameSettings.RotationType = Enum.RotationType.CameraRelative
		UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
	else
		UserGameSettings.RotationType = Enum.RotationType.MovementRelative
		if self.isRightMouseDown or self.isMiddleMouseDown then
			UserInputService.MouseBehavior = Enum.MouseBehavior.LockCurrentPosition
		else
			UserInputService.MouseBehavior = Enum.MouseBehavior.Default
		end
	end
end

function BaseCamera:UpdateForDistancePropertyChange()
	-- Calling this setter with the current value will force checking that it is still
	-- in range after a change to the min/max distance limits
	self:SetCameraToSubjectDistance(self.currentSubjectDistance)
end

function BaseCamera:SetCameraToSubjectDistance(desiredSubjectDistance)
	local player = Players.LocalPlayer

	local lastSubjectDistance = self.currentSubjectDistance

	-- By default, camera modules will respect LockFirstPerson and override the currentSubjectDistance with 0
	-- regardless of what Player.CameraMinZoomDistance is set to, so that first person can be made
	-- available by the developer without needing to allow players to mousewheel dolly into first person.
	-- Some modules will override this function to remove or change first-person capability.
	if player.CameraMode == Enum.CameraMode.LockFirstPerson then
		self.currentSubjectDistance = 0.5
		if not self.inFirstPerson then
			self:EnterFirstPerson()
		end
	else
		local newSubjectDistance = Util.Clamp(player.CameraMinZoomDistance, player.CameraMaxZoomDistance, desiredSubjectDistance)
		if newSubjectDistance < FIRST_PERSON_DISTANCE_THRESHOLD then
			self.currentSubjectDistance = 0.5
			if not self.inFirstPerson then
				self:EnterFirstPerson()
			end
		else
			self.currentSubjectDistance = newSubjectDistance
			if self.inFirstPerson then
				self:LeaveFirstPerson()
			end
		end
	end

	-- Pass target distance and zoom direction to the zoom controller
	ZoomController.SetZoomParameters(self.currentSubjectDistance, math.sign(desiredSubjectDistance - lastSubjectDistance))

	-- Returned only for convenience to the caller to know the outcome
	return self.currentSubjectDistance
end

function BaseCamera:SetCameraType( cameraType )
	--Used by derived classes
	self.cameraType = cameraType
end

function BaseCamera:GetCameraType()
	return self.cameraType
end
-- Public Functions


function GameManager:Initialize()
	MapManager:SaveMap()
end

function GameManager:RunIntermission()
	IntermissionRunning = true
	TimeManager:StartTimer(Configurations.INTERMISSION_DURATION)
	DisplayManager:StartIntermission()
	EnoughPlayers = Players.NumPlayers >= Configurations.MIN_PLAYERS	
	DisplayManager:UpdateTimerInfo(true, not EnoughPlayers)
	spawn(function()
		repeat
			if EnoughPlayers and Players.NumPlayers < Configurations.MIN_PLAYERS then
				EnoughPlayers = false
			elseif not EnoughPlayers and Players.NumPlayers >= Configurations.MIN_PLAYERS then
				EnoughPlayers = true
			end
			DisplayManager:UpdateTimerInfo(true, not EnoughPlayers)
			wait(.5)
		until IntermissionRunning == false
	end)
	
	wait(Configurations.INTERMISSION_DURATION)
	IntermissionRunning = false
end

function GameManager:StopIntermission()
	--IntermissionRunning = false
	DisplayManager:UpdateTimerInfo(false, false)
	DisplayManager:StopIntermission()
end

function GameManager:GameReady()
	return Players.NumPlayers >= Configurations.MIN_PLAYERS
end

function GameManager:StartRound()
	TeamManager:ClearTeamScores()
	PlayerManager:ClearPlayerScores()
	
	PlayerManager:AllowPlayerSpawn(true)
	PlayerManager:LoadPlayers()
	
	GameRunning = true
	PlayerManager:SetGameRunning(true)
	TimeManager:StartTimer(Configurations.ROUND_DURATION)
end

function GameManager:Update()
	--TODO: Add custom custom game code here
end

function GameManager:RoundOver()
	local winningTeam = TeamManager:HasTeamWon()
	if winningTeam then
		DisplayManager:DisplayVictory(winningTeam)
		return true
	end
	if TimeManager:TimerDone() then
		if TeamManager:AreTeamsTied() then
			DisplayManager:DisplayVictory('Tie')
		else
			winningTeam = TeamManager:GetWinningTeam()
			DisplayManager:DisplayVictory(winningTeam)
		end
		return true
	end
	return false
end

function GameManager:RoundCleanup()
	PlayerManager:SetGameRunning(false)
	wait(Configurations.END_GAME_WAIT)
	PlayerManager:AllowPlayerSpawn(false)
	PlayerManager:DestroyPlayers()
	DisplayManager:DisplayVictory(nil)
	TeamManager:ClearTeamScores()
	PlayerManager:ClearPlayerScores()
	TeamManager:ShuffleTeams()
	MapManager:ClearMap()
	MapManager:LoadMap()
	
end
--[[
	Iterates over a Pages object for paginated web requests
	Based on code sample from: https://create.roblox.com/docs/reference/engine/classes/Pages
--]]



local function iterateOverPagesAsync(pages: Pages)
	return coroutine.wrap(function()
		local pageNumber = 1

		while true do
			for _, item in ipairs(pages:GetCurrentPage()) do
				coroutine.yield(item, pageNumber)
			end

			if pages.IsFinished then
				break
			end

			pages:AdvanceToNextPageAsync()

			pageNumber += 1
		end
	end)
end

return iterateOverPagesAsync
--// # key, ManOn


mouse.KeyDown:connect(function(key)
	if key=="u" then 
		veh.Lightbar.middle.Man:Play()
		veh.Lightbar.middle.Wail.Volume = 0
		veh.Lightbar.middle.Yelp.Volume = 0
		veh.Lightbar.middle.Priority.Volume = 0
		script.Parent.Parent.Sirens.Man.BackgroundColor3 = Color3.fromRGB(215, 135, 110)
	end
end)
--		print(AnimName .. " " .. Index .. " [" .. OrigRoll .. "]")


		local Anim = AnimTable[AnimName][Index].Anim

		-- load it to the humanoid; get AnimationTrack
		CurrentAnimTrack = Humanoid:LoadAnimation(Anim)
		 
		-- play the animation
		CurrentAnimTrack:Play(TransitionTime)
		CurrentAnim = AnimName

		-- set up Keyframe Name triggers
		if CurrentAnimKeyframeHandler then
			CurrentAnimKeyframeHandler:disconnect()
		end
		CurrentAnimKeyframeHandler = CurrentAnimTrack.KeyframeReached:connect(KeyframeReachedFunc)
	end
end
--		RightShoulder.MaxVelocity = 0.5
--		LeftShoulder.MaxVelocity = 0.5


		LimbAmplitude = 1
		LimbFrequency = 9
		NeckAmplitude = 0
		NeckFrequency = 0
		NeckDesiredAngle = 0
		ClimbFudge = math.pi
	else
		LimbAmplitude = 0.1
		LimbFrequency = 1
		NeckAmplitude = 0.25
		NeckFrequency = 1.25
	end

	local NeckDesiredAngle = ((not NeckDesiredAngle and (NeckAmplitude * math.sin(Time * NeckFrequency))) or NeckDesiredAngle)
	local LimbDesiredAngle = (LimbAmplitude * math.sin(Time * LimbFrequency))
	
	for _, motor in next, Limbs do 
		if string.match(motor.Name, "Left") or string.match(motor.Name, "Front") or string.match(motor.Name, "Right") or string.match(motor.Name, "Back") then
			motor.MaxVelocity = (Pose == "Running" and 0.05) or (Pose == "Climbing" and 0.5) or 0.1			
			motor.DesiredAngle = LimbDesiredAngle
		elseif string.match(motor.Name, "Neck") then
			motor.DesiredAngle = NeckDesiredAngle
		end
	end
	
	for _, motor in next, Joints do 
		motor.DesiredAngle = (LimbDesiredAngle + ClimbFudge)
	end
	
	--Neck.DesiredAngle = NeckDesiredAngle
--[=[
	Wraps the :WaitForChild API with a promise

	@function promiseChild
	@param parent Instance
	@param name string
	@param timeOut number?
	@return Promise<Instance>
	@within promiseChild
]=]


return function(parent, name, timeOut)
	local result = parent:FindFirstChild(name)
	if result then
		return Promise.resolved(result)
	end

	return Promise.spawn(function(resolve, reject)
		local child = parent:WaitForChild(name, timeOut)

		if child then
			resolve(child)
		else
			reject("Timed out")
		end
	end)
end
-- 16-18


module.Subcategory.Accessories = 19
module.Subcategory.HairAccessories = 20
module.Subcategory.FaceAccessories = 21
module.Subcategory.NeckAccessories = 22
module.Subcategory.ShoulderAccessories = 23
module.Subcategory.FrontAccessories = 24
module.Subcategory.BackAccessories = 25
module.Subcategory.WaistAccessories = 26
module.Subcategory.AvatarAnimations = 27
-- ================================================================================
-- LOCAL FUNCTIONS
-- ================================================================================


local function countdown()
	-- Show GUI
	TimerFrame.Visible = true
	
	-- Set time remaining to countdown duration
	local timeRemaining = DURATION
	
	-- Countdown
	repeat
		Timer.Text = tostring(timeRemaining)
		timeRemaining = timeRemaining - 1
		CountdownBeep:Play()
		wait(1)
	until timeRemaining == 0
	
	CountdownEndBeep:Play()
	-- Hide GUI
	TimerFrame.Visible = false
end
--returns the wielding player of this tool


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

local function setTransparency(object: Instance, transparency: number)
	for i, v in ipairs(object:GetDescendants()) do
		if v:IsA("BasePart") then
			v.Transparency = transparency
		end
	end
end

local function setCollision(object: Instance, collision: boolean)
	for i, v in ipairs(object:GetDescendants()) do
		if v:IsA("BasePart") then
			v.CanCollide = collision
		end
	end
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)

	local Object = Tool.Handle:Clone()

	local PinClone = Object.Details.Top.Handle.Pin:Clone()
	PinClone.CanCollide = true
	PinClone.Archivable = false
	PinClone.Parent = workspace

	game:GetService("Debris"):AddItem(PinClone, 5)

	Object.Details.Top.Handle.Pin.Transparency = 1

	setTransparency(Tool.Handle.Details, 1)

	setCollision(Object.Details, true)

	Object.Parent = workspace
	Object.Fuse:Play()

	Object.Swing.Pitch = Random.new():NextInteger(90, 110) / 100
	Object.Swing:Play()

	Object.CFrame = Tool.Handle.CFrame
	Object.Velocity = (direction * AttackVelocity) + Vector3.new(0, AttackVelocity / 7.5, 0)
	Object.Trail.Enabled = true

	local rand = 11.25
	Object.RotVelocity = Vector3.new(
		Random.new():NextNumber(-rand, rand),
		Random.new():NextNumber(-rand, rand),
		Random.new():NextNumber(-rand, rand)
	)
	Object:SetNetworkOwner(getPlayer())

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

	local ScriptClone = DamageScript:Clone()
	ScriptClone.Parent = Object
	ScriptClone.Disabled = false
end

PowerRemote.OnServerEvent:Connect(function(player, Power)
	local holder = getPlayer()
	if holder ~= player then
		return
	end

	AttackVelocity = Power
end)

TossRemote.OnServerEvent:Connect(function(player, mousePosition)
	local holder = getPlayer()
	if holder ~= player then
		return
	end

	if Cooldown.Value == true then
		return
	end
	Cooldown.Value = true

	if Humanoid and Humanoid.RigType == Enum.HumanoidRigType.R15 then
		TossRemote:FireClient(getPlayer(), "PlayAnimation", "Animation")
	end
	local targetPos = mousePosition.p
	local lookAt = (targetPos - Character.Head.Position).unit

	Toss(lookAt)
	Tool:Destroy()

	--task.wait(CooldownTime)
	--setTransparency(Tool.Handle.Details, 0)

	--Cooldown.Value = false
end)

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

Tool.Unequipped:Connect(function()
	Character = nil
	Humanoid = nil
end)
--[[
	
	Boolean   Keyboard:IsDown(keyCode)
	Boolean   Keyboard:AreAllDown(keyCodes...)
	Boolean   Keyboard:AreAnyDown(keyCodes...)
	
	Keyboard.KeyDown(keyCode)
	Keyboard.KeyUp(keyCode)
	
--]]





local Keyboard = {}

local userInput = game:GetService("UserInputService")


function Keyboard:IsDown(keyCode)
	return userInput:IsKeyDown(keyCode)
end


function Keyboard:AreAllDown(...)
	for _,keyCode in pairs{...} do
		if (not userInput:IsKeyDown(keyCode)) then
			return false
		end
	end
	return true
end


function Keyboard:AreAnyDown(...)
	for _,keyCode in pairs{...} do
		if (userInput:IsKeyDown(keyCode)) then
			return true
		end
	end
	return false
end


function Keyboard:Start()
	
end


function Keyboard:Init()
	
	self.KeyDown = self.Shared.Event.new()
	self.KeyUp = self.Shared.Event.new()
	
	userInput.InputBegan:Connect(function(input, processed)
		if (processed) then return end
		if (input.UserInputType == Enum.UserInputType.Keyboard) then
			self.KeyDown:Fire(input.KeyCode)
		end
	end)
	
	userInput.InputEnded:Connect(function(input, processed)
		if (input.UserInputType == Enum.UserInputType.Keyboard) then
			self.KeyUp:Fire(input.KeyCode)
		end
	end)
	
end


return Keyboard
--[[
	
	\\\ Turn any number (even bigger than 2^47) into a number string w/ commas
	Functions.Commas(
		number,					<-- |REQ|	Any number.
	)
	
--]]




return function(n)
	--- Remove scientific notation
	n = tostring(string.format("%18.0f", tonumber(n) or 0))
	
	--- Convert to commas
	n = (tostring(n):reverse():gsub("(%d%d%d)", "%1,"):reverse()..(tostring(n):match("%.%d+") or "")):gsub("^,", "")
	
	--- Cleanup
	n = string.gsub(n, "%s+", "")
	n = string.sub(n, (string.sub(n, 0, 1) == "," and 2 or 0))
	
	--
	return n
end
--put on startercharacterscripts
--Made Actually like slap battles
--Use this while it lasts because roblox will take it down


local humanoid = script.Parent:WaitForChild("Humanoid")

humanoid.BreakJointsOnDeath = false

humanoid.Died:Connect(function()
	for index,joint in pairs(script.Parent:GetDescendants()) do
		if joint:IsA("Motor6D") then
			local socket = Instance.new("BallSocketConstraint")
			local a1 = Instance.new("Attachment")
			local a2 = Instance.new("Attachment")
			a1.Parent = joint.Part0
			a2.Parent = joint.Part1
			socket.Parent = joint.Parent
			socket.Attachment0 = a1
			socket.Attachment1 = a2
			a1.CFrame = joint.C0
			a2.CFrame = joint.C1
			socket.LimitsEnabled = true
			socket.TwistLimitsEnabled = true
			joint.Enabled = false
		end
	end
end)
--// SS3.33T Police Edit originally for 2017 Mercedes-Benz E300 by Itzt and MASERATl, base SS by Inspare


 
wait(0.1)
local player = game.Players.LocalPlayer
local HUB = script.Parent.HUB
local limitButton = HUB.Limiter
local lightOn = false
local Camera = game.Workspace.CurrentCamera
local cam = script.Parent.nxtcam.Value
local carSeat = script.Parent.CarSeat.Value
local mouse = game.Players.LocalPlayer:GetMouse()
-- FUNCTIONS --


return function(...)
	local Args = {...}


	local TargetPosition = Args[1]
	local fxPos = Vector3.new(TargetPosition.X, TargetPosition.Y - 1.5, TargetPosition.Z)

	local splashAttachment = Instance.new("Attachment")
	splashAttachment.Parent = workspace.Terrain
	splashAttachment.WorldPosition = fxPos
	game.Debris:AddItem(splashAttachment, 5)

	debrisModule.Shockwave(fxPos, 3, 13)

	coroutine.wrap(function()
		for i, v in pairs(script.FX:GetChildren()) do
			if v:IsA("ParticleEmitter") then
				local fx = v:Clone()
				fx.Parent = splashAttachment
				fx:Emit(fx:GetAttribute("EmitCount"))
			end
		end
	end)()

end
-- Libraries


Region = require(Tool.Libraries.Region)
Signal = require(Tool.Libraries.Signal)
Support = require(Tool.Libraries.SupportLibrary)
Try = require(Tool.Libraries.Try)
Make = require(Tool.Libraries.Make)
local Roact = require(Tool.Vendor:WaitForChild 'Roact')
local Maid = require(Tool.Libraries:WaitForChild 'Maid')
local Cryo = require(Tool.Libraries:WaitForChild('Cryo'))
--[[Transmission]]


	Tune.TransModes		= {"Auto", "Semi", "Manual"}								--[[
	[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	= -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.06			-- Gearing determines top speed and wheel torque
	Tune.Ratios			= {				-- Higher ratio = more torque, Lower ratio = higher top speed
		--[[Reverse]]	3.70		,	-- Copy and paste a ratio to add a gear
		--[[Neutral]]	0			,	-- Ratios can also be deleted
		--[[ 1 ]]		3.53		,	-- Reverse, Neutral, and 1st gear are required
		--[[ 2 ]]		2.04		,
		--[[ 3 ]]		1.42		,
		--[[ 4 ]]		0.97		,
		--[[ 5 ]]		0.82		,
		--[[ 6 ]]		0.52		,
	}
	Tune.FDMult			= 1.5			-- Ratio multiplier (Change this value instead of FinalDrive if car is struggling with torque ; Default = 1)
--[[Read line 24 of the script. Just edit the word "D4Tide" to whatever the gun name you want. The gun must be in the lighting for this to work. I'd reccomend you add a regen.]]



local debounce = false

function getPlayer(humanoid) 
local players = game.Players:children() 
for i = 1, #players do 
if players[i].Character.Humanoid == humanoid then return players[i] end 
end 
return nil 
end 

function onTouch(part) 

local human = part.Parent:findFirstChild("Humanoid") 
if (human ~= nil) and debounce == false then

debounce = true

local player = getPlayer(human) 

if (player == nil) then return end 

game.Lighting.AK47:clone().Parent = player.Backpack

wait(5)
debounce = false
end
end


script.Parent.Touched:connect(onTouch)
--[[runservice.RenderStepped:Connect(function(dt : number)
	local frame = 1/dt
	local ratio = frame/64
	print(ratio)
end)]]



runservice.RenderStepped:Connect(function(dt : number)
	if not bool then
		bool = true
		local ct = os.clock()
		local frame = 1/dt
		local ratio = frame/64
		task.wa(0.1 * ratio)
		avgerror = (0.1 - (avgerror + (os.clock() - ct)))/2
		bool = false
	end
end)

task.spawn(function()
	while task.wait(1) do
		print("Average error is "..tostring(avgerror * 100).."%")
	end
end)
-- remap for better lookup


local OPCODE_RM = {
	-- level 1
	[22] = 18, -- JMP
	[31] = 8, -- FORLOOP
	[33] = 28, -- TFORLOOP
	-- level 2
	[0] = 3, -- MOVE
	[1] = 13, -- LOADK
	[2] = 23, -- LOADBOOL
	[26] = 33, -- TEST
	-- level 3
	[12] = 1, -- ADD
	[13] = 6, -- SUB
	[14] = 10, -- MUL
	[15] = 16, -- DIV
	[16] = 20, -- MOD
	[17] = 26, -- POW
	[18] = 30, -- UNM
	[19] = 36, -- NOT
	-- level 4
	[3] = 0, -- LOADNIL
	[4] = 2, -- GETUPVAL
	[5] = 4, -- GETGLOBAL
	[6] = 7, -- GETTABLE
	[7] = 9, -- SETGLOBAL
	[8] = 12, -- SETUPVAL
	[9] = 14, -- SETTABLE
	[10] = 17, -- NEWTABLE
	[20] = 19, -- LEN
	[21] = 22, -- CONCAT
	[23] = 24, -- EQ
	[24] = 27, -- LT
	[25] = 29, -- LE
	[27] = 32, -- TESTSET
	[32] = 34, -- FORPREP
	[34] = 37, -- SETLIST
	-- level 5
	[11] = 5, -- SELF
	[28] = 11, -- CALL
	[29] = 15, -- TAILCALL
	[30] = 21, -- RETURN
	[35] = 25, -- CLOSE
	[36] = 31, -- CLOSURE
	[37] = 35, -- VARARG
}
-- find player's head pos



	local vCharacter = Tool.Parent
	local vPlayer = game.Players:playerFromCharacter(vCharacter)

	local head = vCharacter:findFirstChild("Head")
	if head == nil then return end

	local dir = mouse_pos - head.Position
	dir = computeDirection(dir)

	local launch = head.Position + 5 * dir

	local delta = mouse_pos - launch
	
	local dy = delta.y
	
	local new_delta = Vector3.new(delta.x, 0, delta.z)
	delta = new_delta

	local dx = delta.magnitude
	local unit_delta = delta.unit
	
	-- acceleration due to gravity in RBX units
	local g = (-9.81 * 20)

	local theta = computeLaunchAngle( dx, dy, g)

	local vy = math.sin(theta)
	local xz = math.cos(theta)
	local vx = unit_delta.x * xz
	local vz = unit_delta.z * xz
	

	local missile = Pellet:clone()
        

	Tool.Handle.Mesh:clone().Parent = missile
		

	missile.Position = launch
	missile.Velocity = Vector3.new(vx,vy,vz) * VELOCITY

	missile.PelletScript.Disabled = false

	local creator_tag = Instance.new("ObjectValue")
	creator_tag.Value = vCharacter
	creator_tag.Name = "creator"
	creator_tag.Parent = missile
	
	missile.Parent = game.Workspace

end


function computeLaunchAngle(dx,dy,grav)
	-- arcane
	-- http://en.wikipedia.org/wiki/Trajectory_of_a_projectile
	
	local g = math.abs(grav)
	local inRoot = (VELOCITY*VELOCITY*VELOCITY*VELOCITY) - (g * ((g*dx*dx) + (2*dy*VELOCITY*VELOCITY)))
	if inRoot <= 0 then
		return .25 * math.pi
	end
	local root = math.sqrt(inRoot)
	local inATan1 = ((VELOCITY*VELOCITY) + root) / (g*dx)

	local inATan2 = ((VELOCITY*VELOCITY) - root) / (g*dx)
	local answer1 = math.atan(inATan1)
	local answer2 = math.atan(inATan2)
	if answer1 < answer2 then return answer1 end
	return answer2
end

function computeDirection(vec)
	local lenSquared = vec.magnitude * vec.magnitude
	local invSqrt = 1 / math.sqrt(lenSquared)
	return Vector3.new(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt)
end




Tool.Enabled = true
function onActivated()
	local Torso = Tool.Parent:FindFirstChild("Torso") or Tool.Parent:FindFirstChild("UpperTorso")
	local RightArm = Tool.Parent:FindFirstChild("RightUpperArm")
	local RightShoulder = Torso:FindFirstChild("Right Shoulder") or RightArm:FindFirstChild("RightShoulder")
	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
	if loaded==true then
		loaded=false
		local targetPos = humanoid.TargetPoint

		fire(targetPos)
		wait(.2)
		Tool.Enabled = true
	elseif loaded==false then
		RightShoulder.MaxVelocity = 0.6
		RightShoulder.DesiredAngle = -3.6
		wait(.1)
		Tool.Handle.Transparency=0
		wait(.1)
		loaded=true
	end
	Tool.Enabled = true
end

script.Parent.Activated:connect(onActivated)
--[[Output Scaling Factor]]



	local hpScaling = _Tune.WeightScaling*35
	local FBrakeForce = _Tune.FBrakeForce
	local RBrakeForce = _Tune.RBrakeForce
	local PBrakeForce = _Tune.PBrakeForce
	if not workspace:PGSIsEnabled() then
		hpScaling = _Tune.LegacyScaling*10
		FBrakeForce = _Tune.FLgcyBForce
		RBrakeForce = _Tune.RLgcyBForce
		PBrakeForce = _Tune.LgcyPBForce
	end
--// All global vars will be wiped/replaced except script



return function(data)
	local gui = client.UI.Prepare(script.Parent.Parent)
	local frame = gui.Frame
	local frame2 = frame.Frame
	local msg = frame2.Message
	local ttl = frame2.Title

	local gIndex = data.gIndex
	local gTable = data.gTable

	local title = data.Title
	local message = data.Message
	local scroll = data.Scroll
	local tim = data.Time

	if not data.Message or not data.Title then gTable:Destroy() end

	ttl.Text = title
	msg.Text = message
	
	local function fadeOut()
		for i = 1,12 do
			msg.TextTransparency = msg.TextTransparency+0.05
			ttl.TextTransparency = ttl.TextTransparency+0.05
			msg.TextStrokeTransparency = msg.TextStrokeTransparency+0.05
			ttl.TextStrokeTransparency = ttl.TextStrokeTransparency+0.05
			frame2.BackgroundTransparency = frame2.BackgroundTransparency+0.05
			service.Wait("Stepped")
		end
		service.UnWrap(gui):Destroy()
	end
	
	gTable.CustomDestroy = function()
		fadeOut()
	end

	spawn(function()
		local sound = Instance.new("Sound",service.LocalContainer())
		sound.SoundId = "rbxassetid://7152561753"
		sound.Volume = 0.3
		wait(0.1)
		sound:Play()
		wait(1)
		sound:Destroy()
	end)
	
	gTable.Ready()

	frame:TweenSize(UDim2.new(0, 350, 0, 150), Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 0.2)

	if not tim then
		local _,time = message:gsub(" ","")
		time = math.clamp(time/2,4,11)+1
		wait(time)
	else
		wait(tim)
	end
	
	fadeOut()
end
--//Const


local RS = game:GetService("RunService");

function ViewportInit:Init(VP, Selected, CamCFrame)
	if (not VP) then return; end
	
	local Obj = Selected:Clone();
	
	if (not Obj.PrimaryPart) then
		for i,v in pairs(Obj:GetChildren()) do
			if (v:IsA("BasePart")) then
				Obj.PrimaryPart = v;
				break;
			end
		end	
	end

	Obj:SetPrimaryPartCFrame(CFrame.new(Vector3.new(), CamCFrame.Position))
	Obj.Parent = VP;

	local Camera = Instance.new("Camera");
	VP.CurrentCamera = Camera;
	Camera.Parent = VP;

	local cf = CamCFrame
	Camera.CFrame = cf


	return Obj, Camera;
end

return ViewportInit