Pinkstack/roblox-luau-corpus-text huggingface dataset:
--Gear Ratios


Tune.FinalDrive		= 3.32			-- Gearing determines top speed and wheel torque
Tune.Ratios			= {				-- Higher ratio = more torque, Lower ratio = higher top speed
	--[[Reverse]]	0.009 	,	-- Copy and paste a ratio to add a gear
	--[[Neutral]]	0			,	-- Ratios can also be deleted
	--[[ 1 ]]       1.7		,	-- Reverse, Neutral, and 1st gear are required



}
Tune.FDMult			= 1.5			-- Ratio multiplier (Change this value instead of FinalDrive if car is struggling with torque ; Default = 1)
-- Tries to update the display according to the time (in minutes after midnight), else displays err


function TryUpdate(mins)
	local d_hrsTens, d_hrsOnes, d_minsTens, d_minsOnes, d_noon
	local c_hrs, c_mins
	if mins >= 0 and mins < 1440 then
		c_hrs = math.floor(mins/60)
		c_mins = mins%60
		
		if USE_MILITARY_TIME then
			d_hrsTens = displayMap[math.floor(c_hrs/10)+1]
			d_hrsOnes = displayMap[(c_hrs - (math.floor(c_hrs/10)*10))+1]
			
			-- Special case for 2400
			if c_hrs == 0 and c_mins == 0 then
				d_hrsTens = displayMap[3]
				d_hrsOnes = displayMap[5]
			end
		else
			d_hrsTens = displayMap[math.floor(((c_hrs)%12)/10)+1]
			d_hrsOnes = displayMap[(((c_hrs)%12) - (math.floor(((c_hrs)%12)/10)*10))+1]
			
			-- Special case for 12:00 A/P M
			if c_hrs%12 == 0 then
				d_hrsTens = displayMap[2]
				d_hrsOnes = displayMap[3]
			end
		end
		d_minsTens = displayMap[math.floor(c_mins/10)+1]
		d_minsOnes = displayMap[(c_mins - (math.floor(c_mins/10)*10))+1]
		d_noon = (mins >= 720) and noon_P or noon_A
		
		Display(d_hrsTens, d_hrsOnes, d_minsTens, d_minsOnes, d_noon)
	else
		Error()
	end
end
--[=[
	@within Plasma
	@function label
	@param text string
	@tag widgets

	Text.
]=]


return Runtime.widget(function(text)
	local refs = Runtime.useInstance(function(ref)
		local style = Style.get()

		create("TextLabel", {
			[ref] = "label",
			BackgroundTransparency = 1,
			Font = Enum.Font.SourceSans,
			TextColor3 = style.textColor,
			TextSize = 20,
			RichText = true,
		})

		automaticSize(ref.label)

		return ref.label
	end)

	refs.label.Text = text
end)
-- This is pcalled because the SetCore methods may not be released yet.


pcall(function()
	PlayerBlockedEvent = StarterGui:GetCore("PlayerBlockedEvent")
	PlayerMutedEvent = StarterGui:GetCore("PlayerMutedEvent")
	PlayerUnBlockedEvent = StarterGui:GetCore("PlayerUnblockedEvent")
	PlayerUnMutedEvent = StarterGui:GetCore("PlayerUnmutedEvent")
end)

function SendSystemMessageToSelf(message)
	local currentChannel = ChatWindow:GetCurrentChannel()

	if currentChannel then
		local messageData =
		{
			ID = -1,
			FromSpeaker = nil,
			SpeakerUserId = 0,
			OriginalChannel = currentChannel.Name,
			IsFiltered = true,
			MessageLength = string.len(message),
			Message = trimTrailingSpaces(message),
			MessageType = ChatConstants.MessageTypeSystem,
			Time = os.time(),
			ExtraData = nil,
		}

		currentChannel:AddMessageToChannel(messageData)
	end
end

function MutePlayer(player)
	local mutePlayerRequest = DefaultChatSystemChatEvents:FindFirstChild("MutePlayerRequest")
	if mutePlayerRequest then
		return mutePlayerRequest:InvokeServer(player.Name)
	end
	return false
end

if PlayerBlockedEvent then
	PlayerBlockedEvent.Event:connect(function(player)
		if MutePlayer(player) then
			SendSystemMessageToSelf(string.format("Speaker '%s' has been blocked.", player.Name))
		end
	end)
end

if PlayerMutedEvent then
	PlayerMutedEvent.Event:connect(function(player)
		if MutePlayer(player) then
			SendSystemMessageToSelf(string.format("Speaker '%s' has been muted.", player.Name))
		end
	end)
end

function UnmutePlayer(player)
	local unmutePlayerRequest = DefaultChatSystemChatEvents:FindFirstChild("UnMutePlayerRequest")
	if unmutePlayerRequest then
		return unmutePlayerRequest:InvokeServer(player.Name)
	end
	return false
end

if PlayerUnBlockedEvent then
	PlayerUnBlockedEvent.Event:connect(function(player)
		if UnmutePlayer(player) then
			SendSystemMessageToSelf(string.format("Speaker '%s' has been unblocked.", player.Name))
		end
	end)
end

if PlayerUnMutedEvent then
	PlayerUnMutedEvent.Event:connect(function(player)
		if UnmutePlayer(player) then
			SendSystemMessageToSelf(string.format("Speaker '%s' has been unmuted.", player.Name))
		end
	end)
end
--




local Tool = script.Parent
local upAndAway = false
local humanoid = nil
local head = nil
local upAndAwayForce = Tool.Handle.BodyForce
isfloating=false

local equalizingForce = 236 / 1.2 -- amount of force required to levitate a mass
local gravity = 1.05 -- things float at > 1

local height = nil
local maxRise =  75

function onEquipped()
	Tool.Handle.Mesh.MeshId = "http://www.roblox.com/asset/?id=25498565"
	equipped = true
	Tool.GripPos = Vector3.new(0,-1,0)
	Tool.GripForward = Vector3.new(0,1,0)
	Tool.GripRight = Vector3.new(0,0,-1)
	Tool.GripUp = Vector3.new(1,0,0)
	height = Tool.Parent.Torso.Position.y
	lift = recursiveGetLift(Tool.Parent)
	float(lift)
end

function onUnequipped()
	equipped = false
	Tool.GripForward = Vector3.new(1,0,0)
	Tool.GripRight = Vector3.new(0,0,1)
	Tool.GripUp = Vector3.new(0,1,0)
	Tool.Handle.Mesh.Scale = Vector3.new(1,1,1)
end

Tool.Unequipped:connect(onUnequipped)
Tool.Equipped:connect(onEquipped)
Tool.Handle.Touched:connect(onTouched)

function recursiveGetLift(node)
	local m = 0
	local c = node:GetChildren()
	if (node:FindFirstChild("Head") ~= nil) then head = node:FindFirstChild("Head") end -- nasty hack to detect when your parts get blown off

	for i=1,#c do
		if c[i].className == "Part" then	
			if (head ~= nil and (c[i].Position - head.Position).magnitude < 10) then -- GROSS
				if c[i].Name == "Handle" then
					m = m + (c[i]:GetMass() * equalizingForce * 1) -- hack that makes hats weightless, so different hats don't change your jump height
				else
					m = m + (c[i]:GetMass() * equalizingForce * gravity)
				end
			end
		end
		m = m + recursiveGetLift(c[i])
	end
	return m
end

function updateBalloonSize()
	local range = (height + maxRise) - Tool.Handle.Position.y
	if range < (maxRise/3)*1 then
		Tool.Handle.Mesh.Scale = Vector3.new(3,3,3)
	elseif range < (maxRise/3)*2 then
		Tool.Handle.Mesh.Scale = Vector3.new(2,2,2)
	else
		Tool.Handle.Mesh.Scale = Vector3.new(1,1,1)
	end
end


function float(lift)
	if not isfloating then
		isfloating=true
		while equipped do
			lift=recursiveGetLift(Tool.Parent)
			upAndAwayForce.force=Vector3.new(0,lift*.8,0)
			wait(.2)
			--if Tool.Handle.Position.y > height + maxRise then
			if Tool.Handle.Position.y>300 then
				equipped=false
				Tool.Handle.Pop:Play()
				Tool.GripPos = Vector3.new(0,-.4,0)
				Tool.Handle.Mesh.MeshId = "http://www.roblox.com/asset/?id=26725510"
			end
			updateBalloonSize()
		end
		upAndAwayForce.force=Vector3.new(0,0,0)
		isfloating=false
	end
end
---------------------------
--[[
	--Main anchor point is the DriveSeat <car.DriveSeat>	
	
	Usage:
		MakeWeld(Part1,Part2,WeldType*,MotorVelocity**) *default is "Weld"  **Applies to Motor welds only
		ModelWeld(Model,MainPart)
	Example:
		MakeWeld(car.DriveSeat,misc.PassengerSeat)
		MakeWeld(car.DriveSeat,misc.SteeringWheel,"Motor",.2)
		ModelWeld(car.DriveSeat,misc.Door)
]]
--Weld stuff here


MakeWeld(car.Misc.FrontDoor.base,car.DriveSeat)

MakeWeld(car.Misc.FrontDoor.H1.Dr_1,car.Misc.FrontDoor.H1.part1)
MakeWeld(car.Misc.FrontDoor.H1.Dr_2,car.Misc.FrontDoor.H1.part1)
MakeWeld(car.Misc.FrontDoor.H1.To,car.Misc.FrontDoor.H1.part1)

MakeWeld(car.Misc.FrontDoor.H1.H2.Dr_1,car.Misc.FrontDoor.H1.H2.part1)
MakeWeld(car.Misc.FrontDoor.H1.H2.Dr_2,car.Misc.FrontDoor.H1.H2.part1)
MakeWeld(car.Misc.FrontDoor.H1.H2.Bar_B,car.Misc.FrontDoor.H1.H2.part1)
MakeWeld(car.Misc.FrontDoor.H1.H2.Bar_C,car.Misc.FrontDoor.H1.H2.part1)

MakeWeld(car.Misc.FrontDoor.Lever.A,car.Misc.FrontDoor.Lever.part1)

MakeWeld(car.Misc.FrontDoor.H1.part0,car.Misc.FrontDoor.H1.part1,"Motor",.015).Name="Motor"
MakeWeld(car.Misc.FrontDoor.H1.H2.part0,car.Misc.FrontDoor.H1.H2.part1,"Motor",.03).Name="Motor"

MakeWeld(car.Misc.FrontDoor.Lever.part0,car.Misc.FrontDoor.Lever.part1,"Motor",.04).Name="Motor"

MakeWeld(car.Misc.FrontDoor.H1.part0,car.Misc.FrontDoor.base)

MakeWeld(car.Misc.FrontDoor.Lever.part0,car.Misc.FrontDoor.base)

MakeWeld(car.Misc.FrontDoor.H1.H2.part0,car.Misc.FrontDoor.H1.To)

car.DriveSeat.ChildAdded:connect(function(child)
	if child.Name=="SeatWeld" and child:IsA("Weld") and game.Players:GetPlayerFromCharacter(child.Part1.Parent)~=nil then
		child.C0=CFrame.new(0,-.5,0)*CFrame.fromEulerAnglesXYZ(-(math.pi/2),0,0)
	end
end)
--[=[
	@param class table | (...any) -> any
	@param ... any
	@return any
	Constructs a new object from either the
	table or function given.

	If a table is given, the table's `new`
	function will be called with the given
	arguments.

	If a function is given, the function will
	be called with the given arguments.
	
	The result from either of the two options
	will be added to the trove.

	This is shorthand for `trove:Add(SomeClass.new(...))`
	and `trove:Add(SomeFunction(...))`.

	```lua
	local Signal = require(somewhere.Signal)

	-- All of these are identical:
	local s = trove:Construct(Signal)
	local s = trove:Construct(Signal.new)
	local s = trove:Construct(function() return Signal.new() end)
	local s = trove:Add(Signal.new())

	-- Even Roblox instances can be created:
	local part = trove:Construct(Instance, "Part")
	```
]=]


function Trove:Construct(class, ...)
	if self._cleaning then
		error("Cannot call trove:Construct() while cleaning", 2)
	end
	local object = nil
	local t = type(class)
	if t == "table" then
		object = class.new(...)
	elseif t == "function" then
		object = class(...)
	end
	return self:Add(object)
end
--/Recoil Modification


module.camRecoil = {
	RecoilUp 		= 1
	,RecoilTilt 	= 1
	,RecoilLeft 	= 1
	,RecoilRight 	= 1
}

module.gunRecoil = {
	RecoilUp 		= 1
	,RecoilTilt 	= 1
	,RecoilLeft 	= 1
	,RecoilRight 	= 1
}

module.AimRecoilReduction = 1
module.AimSpreadReduction = 1

module.MinRecoilPower 			= 1
module.MaxRecoilPower 			= 1
module.RecoilPowerStepAmount 	= 1

module.MinSpread 				= .75
module.MaxSpread 				= .75					
module.AimInaccuracyStepAmount 	= 1
module.AimInaccuracyDecrease 	= 1.5
module.WalkMult 				= .75

module.MuzzleVelocityMod	 	= 1

return module
-- METHODS


function IconController.setGameTheme(theme)
	IconController.gameTheme = theme
	local icons = IconController.getIcons()
	for _, icon in pairs(icons) do
		icon:setTheme(theme)
	end
end

function IconController.setDisplayOrder(value)
	value = tonumber(value) or TopbarPlusGui.DisplayOrder
	TopbarPlusGui.DisplayOrder = value
end
IconController.setDisplayOrder(10)

function IconController.getIcons()
	local allIcons = {}
	for otherIcon, _ in pairs(topbarIcons) do
		table.insert(allIcons, otherIcon)
	end
	return allIcons
end

function IconController.getIcon(name)
	for otherIcon, _ in pairs(topbarIcons) do
		if otherIcon.name == name then
			return otherIcon
		end
	end
	return false
end

function IconController.disableHealthbar(bool)
	local finalBool = (bool == nil or bool)
	IconController.healthbarDisabled = finalBool
	IconController.healthbarDisabledSignal:Fire(finalBool)
end

function IconController.disableControllerOption(bool)
	local finalBool = (bool == nil or bool)
	disableControllerOption = finalBool
	if IconController.getIcon("_TopbarControllerOption") then
		IconController._determineControllerDisplay()
	end
end

function IconController.canShowIconOnTopbar(icon)
	if (icon.enabled == true or icon.accountForWhenDisabled) and icon.presentOnTopbar then
		return true
	end
	return false
end

function IconController.getMenuOffset(icon)
	local alignment = icon:get("alignment")
	local alignmentGap = IconController[alignment.."Gap"]
	local extendLeft = 0
	local extendRight = 0
	local additionalRight = 0
	if icon.menuOpen then
		local menuSize = icon:get("menuSize")
		local menuSizeXOffset = menuSize.X.Offset
		local direction = icon:_getMenuDirection()
		if direction == "right" then
			extendRight += menuSizeXOffset + alignmentGap/6--2
		elseif direction == "left" then
			extendLeft = menuSizeXOffset + 4
			extendRight += alignmentGap/3--4
			additionalRight = menuSizeXOffset
		end
	end
	return extendLeft, extendRight, additionalRight
end
--local origWarn = warn


local startTime = time()
local clientLocked = false
local oldInstNew = Instance.new
local oldReq = require
local Folder = script.Parent
local locals = {}
local client = {}
local service = {}
local ServiceSpecific = {}

local function isModule(module)
	for _, modu in client.Modules do
		if rawequal(module, modu) then
			return true
		end
	end
	return false
end

local function logError(...)
	warn("ERROR: ", ...)

	if client and client.Remote then
		client.Remote.Send("LogError", table.concat({ ... }, " "))
	end
end

local oldPrint = print
print = function(...)
	oldPrint(":: Adonis ::", ...)
end
-- Check if player is walking


local check_movement = function()
    if humanoid.WalkSpeed > 7 and humanoid.MoveDirection.Magnitude > 0 and humanoid.FloorMaterial ~= Enum.Material.Air then
        return true
    elseif humanoid.WalkSpeed <= 26 or humanoid.MoveDirection.Magnitude <= 0 or humanoid.FloorMaterial == Enum.Material.Air then
        return false
    end
end
--print(FRP-FLP)



	F = carSeat.AirPhysics 
	
	lv = carSeat.CFrame.lookVector
	uv = carSeat.CFrame.upVector
	rv = carSeat.CFrame.rightVector
	
	if carSeat.Velocity.Y > 0 then
		vy = carSeat.Velocity.Y*50
	else
		if carSeat.Velocity.Y*-70 > 7000 then
		vy = 7000
		else
		vy = carSeat.Velocity.Y*-70
		end
	end
	
	vx = carSeat.Velocity.X*-.5
	vz = carSeat.Velocity.Z*-.5
	
	--F.Force = Vector3.new(vx, vy*1.4, vz)
	F.Force = Vector3.new(0,0,0)
	--print(F.Force)
avw = (carSeat.Parent.Parent.Wheels.FL.Wheel.Position.Y + carSeat.Parent.Parent.Wheels.FR.Wheel.Position.Y + carSeat.Parent.Parent.Wheels.RL.Wheel.Position.Y + carSeat.Parent.Parent.Wheels.RR.Wheel.Position.Y)/4
 if carSeat.Parent.Parent.RW.Pad.Position.Y < carSeat.Parent.Parent.RW.UPad.Position.Y then flpp = true
	count = count + 0.1
else
	count = 0 flpp = false
end

if speed < 3 then
	vlam = 3
else
	vlam = 17
end
if script.Parent.Storage.Autoflip.Value == true then
	if count > vlam then 
	carSeat.Flip.MaxTorque = Vector3.new(400000, 0, 400000) wait(0.5)
	else 
		carSeat.Flip.MaxTorque = Vector3.new(0, 0, 0)
	end
	else carSeat.Flip.MaxTorque = Vector3.new(0, 0, 0)
end
if avw + 2 < script.av.Value or avw - 2 > script.av.Value then
--!strict
--[[
	PlayerModule - This module requires and instantiates the camera and control modules,
	and provides getters for developers to access methods on these singletons without
	having to modify Roblox-supplied scripts.

	2018 PlayerScripts Update - AllYourBlox
--]]



local PlayerModule = {}
PlayerModule.__index = PlayerModule

function PlayerModule.new()
	local self = setmetatable({},PlayerModule)
	self.cameras = require(script:WaitForChild("CameraModule"))
	self.controls = require(script:WaitForChild("ControlModule"))
	self.backpack = require(script:WaitForChild("BackpackModule"))
	return self
end

function PlayerModule:GetCameras()
	return self.cameras
end

function PlayerModule:GetControls()
	return self.controls
end

function PlayerModule:GetClickToMoveController()
	return self.controls:GetClickToMoveController()
end

return PlayerModule.new()
--[[
	PartCache V4.0 by Xan the Dragon // Eti the Spirit -- RBX 18406183
	Update V4.0 has added Luau Strong Type Enforcement.
	
	Creating parts is laggy, especially if they are supposed to be there for a split second and/or need to be made frequently.
	This module aims to resolve this lag by pre-creating the parts and CFraming them to a location far away and out of sight.
	When necessary, the user can get one of these parts and CFrame it to where they need, then return it to the cache when they are done with it.
	
	According to someone instrumental in Roblox's backend technology, zeuxcg (https://devforum.roblox.com/u/zeuxcg/summary)...
		>> CFrame is currently the only "fast" property in that you can change it every frame without really heavy code kicking in. Everything else is expensive.
		
		- https://devforum.roblox.com/t/event-that-fires-when-rendering-finishes/32954/19
	
	This alone should ensure the speed granted by this module.
		
		
	HOW TO USE THIS MODULE:
	
	Look at the bottom of my thread for an API! https://devforum.roblox.com/t/partcache-for-all-your-quick-part-creation-needs/246641
--]]


local table = require(script:WaitForChild("Table"))
-- SETTINGS ----------------------------------------------------


local hasFire = true; -- Exhaust has fire?
local hasSmoke = true; -- Exhaust has smoke?
local lightColor_on = BrickColor.new("Institutional white")
local lightColor_off = headlights[1].BrickColor -- Grab your existing color (recommended)
local brakeColor_on = BrickColor.new("Really red")
local brakeColor_off = BrickColor.new("Reddish brown")
local tiltForce = 1000; -- Force to flip over vehicle
--rayPart					= Instance.new("Part")
--rayPart.Name			= "MG Ray"
--rayPart.Transparency	= .5
--rayPart.Anchored		= true
--rayPart.CanCollide		= false
--rayPart.TopSurface		= Enum.SurfaceType.Smooth
--rayPart.BottomSurface	= Enum.SurfaceType.Smooth
--rayPart.formFactor		= Enum.FormFactor.Custom
--rayPart.BrickColor		= BrickColor.new("Bright yellow")
--rayPart.Reflectance		= 0
--rayPart.Material = Enum.Material.SmoothPlastic



function fireCoax()
	local MGAmmo = tankStats.MGAmmo;
	if MGAmmo.Value <= 0 then
		return false;
	end;
	
	TFE:FireServer('FireMinigun',parts,tankStats,MGDamage,script.Parent)
	
	wait(1/1200*60);
	
	parts.Parent.Gun.MGFlash.Fire.Enabled = true
    wait(0.05);
    parts.Parent.Gun.MGFlash.Fire.Enabled = false
	
	return true;
end
------------- Settings



local Lighting = game.Lighting
local TweenService = game:GetService("TweenService")

function day()
	TweenService:Create(Lighting, TweenInfo.new(Speed), {ClockTime = 12}):Play()
	TweenService:Create(Lighting, TweenInfo.new(Speed), {Brightness = 3.05}):Play()
	TweenService:Create(Lighting, TweenInfo.new(Speed), {Ambient = Color3.fromRGB(106, 130, 186)}):Play()
	TweenService:Create(Lighting, TweenInfo.new(Speed), {ColorShift_Bottom = Color3.fromRGB(0,0,0)}):Play()
end

function night()
	TweenService:Create(Lighting, TweenInfo.new(Speed), {ClockTime = 0}):Play()
	TweenService:Create(Lighting, TweenInfo.new(Speed), {Brightness = 0.4}):Play()
	TweenService:Create(Lighting, TweenInfo.new(Speed), {Ambient = Color3.fromRGB(0,0,0)}):Play()
	TweenService:Create(Lighting, TweenInfo.new(Speed), {ColorShift_Bottom = Color3.fromRGB(0,0,0)}):Play()
end

while true do
	day()
	wait
	night()
	wait
end
-- Modules


local ModuleScripts = ReplicatedStorage.ModuleScripts
local GameSettings = require(ModuleScripts:WaitForChild("GameSettings"))
local PlayerManagement = ServerScriptService.PlayerManagement
local PlayerManagementModules = PlayerManagement.ModuleScripts
local ParticleController = require(PlayerManagementModules.ParticleController)
local Data = ServerScriptService.Data
local DataStore = require(Data.Modules.DataStore)
local UpgradeManager = require(Data.Modules.UpgradeManager)
--Click to Equip Script
--Unless you know what you're doing, do not modify this script.


local tool = script.Parent.Parent --This indicates the tool for the handle.
script.Parent.Parent = tool.Parent --This removes the "Touch to Equip" function for the handle.
script.Parent.ClickDetector.MouseClick:Connect(function(plr) --This detects a click on the handle.
	local character = plr.Character --This identifies the player's character.
	local humanoid = character:FindFirstChild("Humanoid") --This identifies "Humanoid".
	if humanoid ~= nil then --This ensures that "Humanoid" exists inside the player's character.
		tool.Parent = character --This causes the character to equip the tool.
		script.Parent.Parent = tool --This puts the handle inside the tool.
		tool.AncestryChanged:Connect(function(item) --This detects a change in the tool's ancestry.
			local parent = item.Parent --This identifies the parent of the tool.
			if parent.Name ~= "Backpack" and parent ~= character and script.Parent.Parent == tool then
				--The code above ensures the parent isn't the player's backpack or character, and the handle is inside the tool.
				script.Parent.Parent = tool.Parent --This ensures that "Touch to Equip" is disabled.
			end
		end)
	end
end)
-- << SETUP >>


main:GetModule("PageAbout"):UpdateRankName()
main:GetModule("PageAbout"):UpdateProfileIcon()
main:GetModule("PageAbout"):CreateUpdates()
main:GetModule("PageAbout"):UpdateContributors()
main:GetModule("PageAbout"):CreateCredits()
main:GetModule("PageCommands"):CreateCommands()
main:GetModule("PageCommands"):CreateMorphs()
main:GetModule("PageCommands"):CreateDetails()
main:GetModule("PageSpecial"):SetupDonorCommands()
main:GetModule("PageAdmin"):SetupRanks()
main:GetModule("GUIs"):DisplayPagesAccordingToRank()
-------------------------------------Gun info


ToolName="Revolver"
ClipSize=6
ReloadTime=1
Firerate=.2
MinSpread=0.000001
MaxSpread=0.00001
SpreadRate=0
BaseDamage=25
automatic=false
burst=false
shot=false			--Shotgun
BarrlePos=Vector3.new(0,0,0)
Cursors={"rbxasset://textures\\GunCursor.png"}
ReloadCursor="rbxasset://textures\\GunWaitCursor.png"
-- this will need to be worked into a client schema later


local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CollectionService = game:GetService("CollectionService")
local Players = game:GetService("Players")

local taggedButtons = CollectionService:GetTagged("LightupButton")

local buttons = {}
local characters = {}

for _, button in pairs(taggedButtons) do
	buttons[button] = {
		active = false
	}
end


local function onPlayerAdded(player)
	player.CharacterAdded:Connect(function(character)
		repeat task.wait(.2) until character and character.PrimaryPart and character.Humanoid

		characters[player] = character
	end)
	player.CharacterRemoving:Connect(function(character)
		characters[player] = nil
	end)
end

Players.PlayerAdded:Connect(onPlayerAdded)

for _, player in pairs(Players:GetChildren()) do
	onPlayerAdded(player)
end


while true do
	local taggedButtons = CollectionService:GetTagged("LightupButton")

	for _, button in pairs(taggedButtons) do
		if buttons[button] == nil then
			buttons[button] = {
				active = false
			}
		end
	end
	
	for _, button in pairs(buttons) do
		button.active = false
	end
	
	for player, character in pairs(characters) do
		if character and character.PrimaryPart and character.Humanoid then
			local raycastParams = RaycastParams.new()
			raycastParams.FilterDescendantsInstances = taggedButtons
			raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
			local raycastResult = workspace:Raycast(character.PrimaryPart.Position, Vector3.new(0, -6, 0), raycastParams)
			
			if raycastResult and raycastResult.Instance then
				if buttons[raycastResult.Instance] then
					buttons[raycastResult.Instance].active = true
				end
			end
		end
	end
	
	task.wait()
	
	for instance, button in pairs(buttons) do
		if button.active then
			instance.Material = Enum.Material.Neon
		else
			instance.Material = Enum.Material.Plastic
		end
	end
end
-- Making a CFrame value from an origin position and unit direction:


function Util.makeOrientation(sourcePos, dir)
    -- Construct CFrame to rotate parts from x-axis alignment (where they are constructed) to
    -- the world orientation of the arc from a quaternion rotation that describes the
    -- rotation of ux-->axis
    dir = dir.unit

    -- Proportionate angle between ux and direction:
    local angleUxAxis = dot(ux, dir)

    if (angleUxAxis > 0.99999) then
        return cframe(sourcePos, sourcePos - uz)
    elseif (angleUxAxis < -0.99999) then
        return cframe(sourcePos, sourcePos + uz)
    else
        local q = cross(ux, dir)
        local qw = 1 + angleUxAxis
        local qnorm = sqrt(q.magnitude ^ 2 + qw * qw)
        q = q / qnorm
        qw = qw / qnorm
        return cframe(sourcePos.x, sourcePos.y, sourcePos.z, q.x, q.y, q.z, qw)
    end
end

return Util