Roblox/luau_corpus huggingface dataset:
-------- OMG HAX

r = game:service("RunService")


Tool = script.Parent
hammer = Tool["Left Leg"]





while true do 
	
wait(math.random(4,15))
local damm = script.Parent.Head.Deadly:Clone()
pos = script.Parent["Right Leg"].Position-Vector3.new(0,10,0)
local shockRing = Instance.new("Part")
shockRing.formFactor = 2
shockRing.Size = Vector3.new(1, 0.4, 1)
shockRing.Anchored = true
shockRing.Locked = true
shockRing.CanCollide = false
shockRing.archivable = false
shockRing.TopSurface = 0
shockRing.BottomSurface = 0
shockRing.Transparency = 1
damm.Parent = shockRing
local decal = Instance.new("Decal")
decal.Face = 1
decal.Texture = "http://www.roblox.com/asset/?version=1&id=1280730"
decal.Parent = shockRing

local bottomDecal = decal:Clone()
bottomDecal.Face = 4
bottomDecal.Parent = shockRing
shockRing.CFrame = CFrame.new(pos)
for x = 1, 29 do
delay(x / 30, function()	shockRing.Parent = nil	shockRing.Size = Vector3.new(0, 0.4, 0) + Vector3.new(6.4, 0, 6.4) * x	shockRing.Parent = Tool	end)
end
delay(1, function() shockRing.Parent = nil end)


hammer.Boom:Play()



end
--

function Triangle:SetParent(parent)
	self.Beam.Parent = parent
	self.Attachment0.Parent = parent
	self.Attachment1.Parent = parent
	self.Parent = parent
end

function Triangle:SetBeamProperties(properties)
	for prop, value in next, properties do
		self.Beam[prop] = value
	end
end

function Triangle:Draw(a, b, c)
	a = a or self.a
	b = b or self.b
	c = c or self.c
	
	self.a = a
	self.b = b
	self.c = c
	
	local ab, ac, bc = b - a, c - a, c - b
	local abd, acd, bcd = ab:Dot(ab), ac:Dot(ac), bc:Dot(bc)
	
	if (abd > acd and abd > bcd) then
		c, a = a, c
	elseif (acd > bcd and acd > abd) then
		a, b = b, a
	end
	
	ab, ac, bc = b - a, c - a, c - b
	
	local normal = ab:Cross(ac).Unit
	local height = normal:Cross(ab).Unit
	
	local parentInv = self.Parent.CFrame:Inverse()
	self.Attachment0.CFrame = parentInv * CFrame.fromMatrix((a + b)/2, height, ab, normal)
	self.Attachment1.CFrame = parentInv * CFrame.new(c)
	self.Beam.Width0 = (a - b).Magnitude
end
-- constants

local CUSTOMIZATION	= ReplicatedStorage.Customization
local PLAYER_DATA	= ReplicatedStorage.PlayerData
local REMOTES		= ReplicatedStorage.Remotes

local MAX_SLOTS	= 5
local SLOT_SIZE	= 30
--[[ @brief Runs all currently queued functions.
--]]
function FunctionQueue:Dispatch()
	for i, v in pairs(self._Functions) do
		local f = v[1];
		local args = v[2];
		local co = coroutine.create(f);
		local success, error = coroutine.resume(co, unpack(args));
		if not success then
			Log.Warn("Function %s terminated with an error: %s", f, error);
		end
	end
	self._Functions = {};
end
-- WorldSize -> ScreenSize
function ScreenSpace.WorldWidthToScreenWidth(worldWidth, depth)
	local aspectRatio = ScreenSpace.AspectRatio()
	local hfactor = math.tan(math.rad(workspace.CurrentCamera.FieldOfView)/2)
	local wfactor = aspectRatio*hfactor
	local sx = ScreenSpace.ViewSizeX()
	--
	return -(worldWidth * sx) / (2 * wfactor * depth)
end
function ScreenSpace.WorldHeightToScreenHeight(worldHeight, depth)
	local hfactor = math.tan(math.rad(workspace.CurrentCamera.FieldOfView)/2)
	local sy = ScreenSpace.ViewSizeY()
	--
	return -(worldHeight * sy) / (2 * hfactor * depth)
end
-- float rd_flt_le(string src, int s)
-- @src - Source binary string
-- @s - Start index of little endian float
local function rd_flt_le(src, s) return rd_flt_basic(string.byte(src, s, s + 3)) end
--[[
	Constants used throughout the testing framework.
]]

local TestEnum = {}

TestEnum.TestStatus = {
	Success = "Success",
	Failure = "Failure",
	Skipped = "Skipped"
}

TestEnum.NodeType = {
	Describe = "Describe",
	It = "It",
	BeforeAll = "BeforeAll",
	AfterAll = "AfterAll",
	BeforeEach = "BeforeEach",
	AfterEach = "AfterEach"
}

TestEnum.NodeModifier = {
	None = "None",
	Skip = "Skip",
	Focus = "Focus"
}

return TestEnum
-- update whether the character is running or not
humanoid.Running:Connect(function(speed)
	if speed <= .3 then
		isrunning = false
	else
		isrunning = true
	end
end)
--
if(show_ammo == true) then 
PS.Ammo.ATG.Text = " Minigun Bullets: ".. minigun.total 
PS.Ammo.HM.Text = " Hydra Missile: Left: "..hydra.left..", Right: "..hydra.right
PS.Ammo.Visible = true
elseif(show_ammo == false) then 
PS.Ammo.Visible = false
end
-----------------------------------------ONLY EDIT THESE VALUES!!!!!-----------------------------------------
-----!Instructions!-----
--Make sure you have a part in the gun named Barrel, it is where the raycast will shoot from.--
--Just place this script into any gun and edit the values below.--
--Editting anything else will risk breaking it.--
------------------------
Damage = 20
SPS = 15 -- Shots Per Second, gives a limit of how fast the gun shoots.
Recoil = 3 -- [1-10] [1 = Minigun, 10 = Sniper]
WallShoot = false -- Shoots through walls.
GH = false -- [True = RB can't hurt RB.] [False = RB can hurt RB.]
BulletColor = "Cool yellow" -- Any Brickcolor will work.
Flash = true
-- ================================================================================
-- Settings - Splinter
-- ================================================================================

local Settings = {}

Settings.DefaultSpeed = 555		-- Speed when not boosted [Studs/second, Range 50-300]
Settings.BoostSpeed = 1567		-- Speed when boosted [Studs/second, Maximum: 400]
Settings.BoostAmount = 1.5		-- Duration of boost in seconds
Settings.Steering = 15			-- How quickly the speeder turns [Range: 1-10]
-- Tell owner to show footsteps
game.ReplicatedStorage.Interactions.Client.Perks.AllowDetective:FireClient(script.Owner.Value)
-- This finds the tank that we are controlling
parts = script.Parent.Parent.Parent.Turret.Value;
tankStats = parts.Stats;

game.Workspace.CurrentCamera.CameraType = "Track"
game.Workspace.CurrentCamera.CameraSubject = parts.CameraPart
---- STATE MODIFICATION ----

function ActiveCastStatic:Pause()
	assert(getmetatable(self) == ActiveCastStatic, ERR_NOT_INSTANCE:format("Pause", "ActiveCast.new(...)"))
	assert(self.StateInfo.UpdateConnection ~= nil, ERR_OBJECT_DISPOSED)
	self.StateInfo.Paused = true
end

function ActiveCastStatic:Resume()
	assert(getmetatable(self) == ActiveCastStatic, ERR_NOT_INSTANCE:format("Resume", "ActiveCast.new(...)"))
	assert(self.StateInfo.UpdateConnection ~= nil, ERR_OBJECT_DISPOSED)
	self.StateInfo.Paused = false
end

function ActiveCastStatic:Terminate()
	assert(getmetatable(self) == ActiveCastStatic, ERR_NOT_INSTANCE:format("Terminate", "ActiveCast.new(...)"))
	assert(self.StateInfo.UpdateConnection ~= nil, ERR_OBJECT_DISPOSED)

	-- First: Set EndTime on the latest trajectory since it is now done simulating.
	local trajectories = self.StateInfo.Trajectories
	local lastTrajectory = trajectories[#trajectories]
	lastTrajectory.EndTime = self.StateInfo.TotalRuntime

	-- Disconnect the update connection.
	self.StateInfo.UpdateConnection:Disconnect()

	-- Now fire CastTerminating
	self.Caster.CastTerminating:FireSync(self)

	-- And now set the update connection object to nil.
	self.StateInfo.UpdateConnection = nil

	-- And nuke everything in the table + clear the metatable.
	self.Caster = nil
	self.StateInfo = nil
	self.RayInfo = nil
	self.UserData = nil
	setmetatable(self, nil)
end

return ActiveCastStatic
-- Protected
function BaseState:_Enter()
	self.offStateTime = 0
	self:Enter()
end
--// Damage Settings	
	BaseDamage = 38; -- Torso Damage
	LimbDamage = 30; -- Arms and Legs
	ArmorDamage = 18; -- How much damage is dealt against armor (Name the armor "Armor")
	HeadDamage = 1000; -- If you set this to 100, there's a chance the player won't die because of the heal script
--[=[
	@return Promise
	Starts Knit. Should only be called once per client.
	```lua
	Knit.Start():andThen(function()
		print("Knit started!")
	end):catch(warn)
	```

	By default, service methods exposed to the client will return promises.
	To change this behavior, set the `ServicePromises` option to `false`:
	```lua
	Knit.Start({ServicePromises = false}):andThen(function()
		print("Knit started!")
	end):catch(warn)
	```
]=]
function KnitClient.Start(options: KnitOptions?)
	if started then
		return Promise.reject("Knit already started")
	end

	started = true

	if options == nil then
		selectedOptions = defaultOptions
	else
		assert(typeof(options) == "table", `KnitOptions should be a table or nil; got {typeof(options)}`)
		selectedOptions = options
		for k, v in defaultOptions do
			if selectedOptions[k] == nil then
				selectedOptions[k] = v
			end
		end
	end
	if type(selectedOptions.PerServiceMiddleware) ~= "table" then
		selectedOptions.PerServiceMiddleware = {}
	end

	return Promise.new(function(resolve)
		-- Init:
		local promisesStartControllers = {}

		for _, controller in controllers do
			if type(controller.KnitInit) == "function" then
				table.insert(
					promisesStartControllers,
					Promise.new(function(r)
						debug.setmemorycategory(controller.Name)
						controller:KnitInit()
						r()
					end)
				)
			end
		end

		resolve(Promise.all(promisesStartControllers))
	end):andThen(function()
		-- Start:
		for _, controller in controllers do
			if type(controller.KnitStart) == "function" then
				task.spawn(function()
					debug.setmemorycategory(controller.Name)
					controller:KnitStart()
				end)
			end
		end

		startedComplete = true
		onStartedComplete:Fire()

		task.defer(function()
			onStartedComplete:Destroy()
		end)
	end)
end
--local speed = script.Parent.Speed
local tweenInfo = TweenInfo.new(
	speed, -- Length (seconds)
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	0, -- times repeared
	false, -- reverse
	delayed -- delay
)

goals[ 1 ] = spin.CFrame * CFrame.Angles( 0, math.rad( -30 ), 0 )
goals[ 2 ] = spin.CFrame * CFrame.Angles( 0, math.rad( -60 ), 0 )
goals[ 3 ] = spin.CFrame * CFrame.Angles( 0, math.rad( -90 ), 0 )
goals[ 4 ] = spin.CFrame * CFrame.Angles( 0, math.rad( -120 ), 0 )
goals[ 5 ] = spin.CFrame * CFrame.Angles( 0, math.rad( -150 ), 0 )
goals[ 6 ] = spin.CFrame * CFrame.Angles( 0, math.rad( -180 ), 0 )
goals[ 7 ] = spin.CFrame * CFrame.Angles( 0, math.rad( -210 ), 0 )
goals[ 8 ] = spin.CFrame * CFrame.Angles( 0, math.rad( -240 ), 0 )
goals[ 9 ] = spin.CFrame * CFrame.Angles( 0, math.rad( -270 ), 0 )
goals[ 10 ] = spin.CFrame * CFrame.Angles( 0, math.rad( -300 ), 0 )
goals[ 11 ] = spin.CFrame * CFrame.Angles( 0, math.rad( -330 ), 0 )
goals[ 12 ] = spin.CFrame

local i = 0
while spinning do
	i = i % #goals + 1

	local tween = TweenService:Create( spin, tweenInfo, { CFrame = goals[ i ] } )
	tween:Play()

	local state = tween.Completed:Wait()
	if state == Enum.PlaybackState.Cancelled then
		warn( 'Tween cancelled' )
		break
	end
end
--- Replaces arguments in the format $1, $2, $something with whatever the
-- given function returns for it.
function Util.SubstituteArgs(str, replace)
	str = encodeCommandEscape(str)
	-- Convert numerical keys to strings
	if type(replace) == "table" then
		for i = 1, #replace do
			local k = tostring(i)
			replace[k] = replace[i]

			if replace[k]:find("%s") then
				replace[k] = string.format("%q", replace[k])
			end
		end
	end
	return decodeCommandEscape(str:gsub("($%d+)%b{}", "%1"):gsub("$(%w+)", replace))
end
--[=[
	Unpacks the brio, and then repacks it. Ignored items
	still invalidate the previous brio

	@since 3.6.0
	@param predicate (T) -> boolean
	@return (source: Observable<Brio<T>>) -> Observable<Brio<T>>
]=]
function RxBrioUtils.where(predicate)
	assert(type(predicate) == "function", "Bad predicate")
	return function(source)
		return Observable.new(function(sub)
			local maid = Maid.new()

			maid:GiveTask(source:Subscribe(function(brio)
				assert(Brio.isBrio(brio), "Not a brio")
				if brio:IsDead() then
					return
				end

				if predicate(brio:GetValue()) then
					sub:Fire(brio)
				end
			end, sub:GetFailComplete()))

			return maid
		end)
	end
end
-- Auto saving and issue queue managing:
RunService.Heartbeat:Connect(function()
	-- 1) Auto saving: --
	local auto_save_list_length = #AutoSaveList
	if auto_save_list_length > 0 then
		local auto_save_index_speed = SETTINGS.AutoSaveProfiles / auto_save_list_length
		local os_clock = os.clock()
		while os_clock - LastAutoSave > auto_save_index_speed do
			LastAutoSave = LastAutoSave + auto_save_index_speed
			local profile = AutoSaveList[AutoSaveIndex]
			if os_clock - profile._load_timestamp < SETTINGS.AutoSaveProfiles then
				-- This profile is freshly loaded - auto-saving immediately after loading will cause a warning in the log:
				profile = nil
				for i = 1, auto_save_list_length - 1 do
					-- Move auto save index to the right:
					AutoSaveIndex = AutoSaveIndex + 1
					if AutoSaveIndex > auto_save_list_length then
						AutoSaveIndex = 1
					end
					profile = AutoSaveList[AutoSaveIndex]
					if os_clock - profile._load_timestamp >= SETTINGS.AutoSaveProfiles then
						break
					else
						profile = nil
					end
				end
			end
			-- Move auto save index to the right:
			AutoSaveIndex = AutoSaveIndex + 1
			if AutoSaveIndex > auto_save_list_length then
				AutoSaveIndex = 1
			end
			-- Perform save call:
			-- print("[ProfileService]: Auto updating profile - profile_store_name = \"" .. profile._profile_store._profile_store_name .. "\"; profile_key = \"" .. profile._profile_key .. "\"")
			if profile ~= nil then
				coroutine.wrap(SaveProfileAsync)(profile) -- Auto save profile in new thread
			end
		end
	end
	-- 2) Issue queue: --
	-- Critical state handling:
	if ProfileService.CriticalState == false then
		if #IssueQueue >= SETTINGS.IssueCountForCriticalState then
			ProfileService.CriticalState = true
			ProfileService.CriticalStateSignal:Fire(true)
			CriticalStateStart = os.clock()
			warn("[ProfileService]: Entered critical state")
		end
	else
		if #IssueQueue >= SETTINGS.IssueCountForCriticalState then
			CriticalStateStart = os.clock()
		elseif os.clock() - CriticalStateStart > SETTINGS.CriticalStateLast then
			ProfileService.CriticalState = false
			ProfileService.CriticalStateSignal:Fire(false)
			warn("[ProfileService]: Critical state ended")
		end
	end
	-- Issue queue:
	while true do
		local issue_time = IssueQueue[1]
		if issue_time == nil then
			break
		elseif os.clock() - issue_time > SETTINGS.IssueLast then
			table.remove(IssueQueue, 1)
		else
			break
		end
	end
end)
-- Define the function to open or close the window with gene-alike effect
local function toggleWindow()
	if window.Visible then
		-- Close the window by tweening back to the button position and size
		window:TweenSizeAndPosition(
			UDim2.new(0, 0, 0, 0),
			UDim2.new(0, gClippslyButton.AbsolutePosition.X, 0, gClippslyButton.AbsolutePosition.Y),
			'Out',
			'Quad',
			0.5,
			false,
			function()
				window.Visible = false
			end
		)
	else
		-- Set the initial position of the window to be relative to the button
		local startPos = UDim2.new(0, gClippslyButton.AbsolutePosition.X, 0, gClippslyButton.AbsolutePosition.Y)
		window.Position = startPos

		-- Set the initial size of the window to be zero
		window.Size = UDim2.new(0, 0, 0, 0)

		-- Show the window and tween its position and size from the button position and size to its original position and size
		window.Visible = true
		window:TweenSizeAndPosition(
			UDim2.new(0.565, 0, 0.694, 0),
			UDim2.new(0.218, 0, 0.133, 0),
			'Out',
			'Quad',
			0.5
		)
	end
end
--Visiblity
uis = game:GetService("UserInputService")
ismobile = uis.TouchEnabled
button.Visible = ismobile

local states = {
	OFF = "rbxasset://textures/ui/mouseLock_off@2x.png",
	ON = "rbxasset://textures/ui/mouseLock_on@2x.png"
}
local MAX_LENGTH = 900000
local active = false
local ENABLED_OFFSET = CFrame.new(1.7, 0, 0)
local DISABLED_OFFSET = CFrame.new(-1.7, 0, 0)
local function UpdateImage(STATE)
	button.Image = states[STATE]
end

local function GetUpdatedCameraCFrame(ROOT, CAMERA)
	return CFrame.new(root.Position, Vector3.new(CAMERA.CFrame.LookVector.X * MAX_LENGTH, root.Position.Y, CAMERA.CFrame.LookVector.Z * MAX_LENGTH))
end
local function EnableShiftlock()
	UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
	humanoid.AutoRotate = false

	UpdateImage("ON")
	if humanoid:GetState() ~= Enum.HumanoidStateType.PlatformStanding and humanoid:GetState() ~= Enum.HumanoidStateType.Swimming and humanoid.Health > 0 and Settings.Downed.Value == false and Settings.Ragdoll.Value == false then
		root.CFrame = GetUpdatedCameraCFrame(root, camera)
		camera.CFrame = camera.CFrame * ENABLED_OFFSET
	else

	end

end
local function DisableShiftlock()
	UserInputService.MouseBehavior = Enum.MouseBehavior.Default
	humanoid.AutoRotate = true
	UpdateImage("OFF")
	camera.CFrame = camera.CFrame * DISABLED_OFFSET
	pcall(function()
		active:Disconnect()
		active = nil
	end)
end
UpdateImage("OFF")
active = false
function ShiftLock()
	if not active then
		active = runservice.RenderStepped:Connect(function()
			EnableShiftlock()
		end)
	else
		DisableShiftlock()
	end
end
local ShiftLockButton = CAS:BindAction("ShiftLOCK", ShiftLock, false, "On")
CAS:SetPosition("ShiftLOCK", UDim2.new(0.8, 0, 0.8, 0))
button.MouseButton1Click:Connect(function()
	if not active then
		active = runservice.RenderStepped:Connect(function()
			EnableShiftlock()
		end)
	else
		DisableShiftlock()
	end
end)
return MobileCameraFramework
--------RIGHT DOOR --------
game.Workspace.doorright.l11.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l23.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l32.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l41.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l53.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l62.BrickColor = BrickColor.new(1023)
game.Workspace.doorright.l71.BrickColor = BrickColor.new(1023)

game.Workspace.doorright.l12.BrickColor = BrickColor.new(106)
game.Workspace.doorright.l21.BrickColor = BrickColor.new(106)
game.Workspace.doorright.l33.BrickColor = BrickColor.new(106)
game.Workspace.doorright.l42.BrickColor = BrickColor.new(106)
game.Workspace.doorright.l51.BrickColor = BrickColor.new(106)
game.Workspace.doorright.l63.BrickColor = BrickColor.new(106)
game.Workspace.doorright.l72.BrickColor = BrickColor.new(106)

game.Workspace.doorright.l13.BrickColor = BrickColor.new(1013)
game.Workspace.doorright.l22.BrickColor = BrickColor.new(1013)
game.Workspace.doorright.l31.BrickColor = BrickColor.new(1013)
game.Workspace.doorright.l43.BrickColor = BrickColor.new(1013)
game.Workspace.doorright.l52.BrickColor = BrickColor.new(1013)
game.Workspace.doorright.l61.BrickColor = BrickColor.new(1013)
game.Workspace.doorright.l73.BrickColor = BrickColor.new(1013)

game.Workspace.doorright.pillar.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.Lighting.flashcurrent.Value = "13"
-- Start the shimmer
local function startShimmer()
	shim:Play()
end
startShimmer()
--Front Suspension
Tune.FSusDamping	= 15		-- Spring Dampening
Tune.FSusStiffness	= 150	-- Spring Force
Tune.FAntiRoll 		= 1	-- Anti-Roll (Gyro Dampening)

Tune.FSusLength		= 5		-- Suspension length (in studs)
Tune.FPreCompress	= 5		-- Pre-compression adds resting length force
Tune.FExtensionLim	= .3		-- Max Extension Travel (in studs)
Tune.FCompressLim	= .5		-- Max Compression Travel (in studs)
Tune.FSusAngle		= 80		-- Suspension Angle (degrees from horizontal)

Tune.FWsBoneLen		= 5			-- Wishbone Length
Tune.FWsBoneAngle	= 0			-- Wishbone angle (degrees from horizontal)
Tune.FAnchorOffset	= {			-- Suspension anchor point offset (relative to center of wheel)
	--[[Lateral]]		-.4		,	-- positive = outward
	--[[Vertical]]		-.5		,	-- positive = upward
	--[[Forward]]		0		}	-- positive = forward
--[[Weight and CG]]
	Tune.Weight			= 3600		-- Total weight (in pounds)
	Tune.WeightBSize	= {			-- Size of weight brick (dimmensions in studs ; larger = more stable)
	 --[[Width]]		6		,
	 --[[Height]]		3.5		,
	 --[[Length]]		14		}
	Tune.WeightDist		= 50		-- Weight distribution (0 - on rear wheels, 100 - on front wheels, can be <0 or >100)
	Tune.CGHeight		= .8		-- Center of gravity height (studs relative to median of all wheels)
	Tune.WBVisible		= false		-- Makes the weight brick visible
	
	--Unsprung Weight
	Tune.FWheelDensity	= .1		-- Front Wheel Density
	Tune.RWheelDensity	= .1		-- Rear Wheel Density
	Tune.FWLgcyDensity	= 1			-- Front Wheel Density [PGS OFF]
	Tune.RWLgcyDensity	= 1			-- Rear Wheel Density [PGS OFF]
	
	Tune.AxleSize		= 2			-- Size of structural members (larger = more stable/carry more weight)
	Tune.AxleDensity	= .1		-- Density of structural members
-- Continuously compute a new body orientation to face the camera, and notify the server for replication
-- Intended to be used for the local player's character
function OrientableBody:useCameraAsSource()
	local timeSinceLastSync = 0
	self.renderStepConnection = RunService.RenderStepped:Connect(function(delta)
		local camera = workspace.CurrentCamera
		if not camera then
			return
		end

		local orientation = self:face(camera.CFrame.LookVector)

		timeSinceLastSync += delta
		if timeSinceLastSync > Constants.SYNC_INTERVAL and orientation then
			timeSinceLastSync %= Constants.SYNC_INTERVAL
			updateBodyOrientation:FireServer(orientation)
		end
	end)
end
--[[
	A ref is nothing more than a binding with a special field 'current'
	that maps to the getValue method of the binding
]]
local Binding = require(script.Parent.Binding)

local function createRef()
	local binding, _ = Binding.create(nil)

	local ref = {}

	--[[
		A ref is just redirected to a binding via its metatable
	]]
	setmetatable(ref, {
		__index = function(self, key)
			if key == "current" then
				return binding:getValue()
			else
				return binding[key]
			end
		end,
		__newindex = function(self, key, value)
			if key == "current" then
				error("Cannot assign to the 'current' property of refs", 2)
			end

			binding[key] = value
		end,
		__tostring = function(self)
			return ("RoactRef(%s)"):format(tostring(binding:getValue()))
		end,
	})

	return ref
end

return createRef
-- Event Bindings
DisplayIntermission.OnClientEvent:connect(OnDisplayIntermission)
--[[
	Remove elements from a dictionary
]]
function Immutable.RemoveFromDictionary(dictionary, ...)
	local result = {}

	for key, value in pairs(dictionary) do
		local found = false
		for listKey = 1, select("#", ...) do
			if key == select(listKey, ...) then
				found = true
				break
			end
		end
		if not found then
			result[key] = value
		end
	end

	return result
end
-- For effects and stuff
local function Engine(on)
	local prop = plane.Propeller
	
	if on then
		prop.Hinge.DesiredAngle = 1e100 -- Super huge number so the propeller doesn't stop spinning :D
	else
		local angle = math.random(0, 10)
		prop.Hinge.DesiredAngle = angle
		prop.Hinge.CurrentAngle = angle
	end
end

seat.Changed:connect(function(p)
	if p == "Occupant" then
		local occupant = seat.Occupant
		
		if occupant then
			Engine(true)
			local player = game.Players:GetPlayerFromCharacter(occupant.Parent)
			if player then
				plane.Body:SetNetworkOwner(player)
				local localPlaneScript = script.LocalPlaneScript:Clone()
				localPlaneScript.Parent = player.PlayerGui
				localPlaneScript.Plane.Value = plane
				localPlaneScript.Disabled = false
			else
				shooting = false
			end
		else
			Engine(false)
		end
	end
end)

while true do
	if seat.Occupant and shooting then
		for _, gun in pairs(plane.Guns:GetChildren()) do
			if gun:FindFirstChild("Muzzle") then
				local bullet = Instance.new("Part")
				bullet.Parent = gun
				bullet.Anchored = false
				bullet.CanCollide = false
				bullet.FormFactor = Enum.FormFactor.Custom
				bullet.Size = Vector3.new(0.4, 10, 0.4)
				bullet.BrickColor = BrickColor.new("Bright yellow")
				bullet.Material = Enum.Material.Neon
				Instance.new("CylinderMesh", bullet)
				Instance.new("BodyForce", bullet).Force = Vector3.new(0, bullet:GetMass() * 196.2, 0)
				bullet.CFrame = gun.Muzzle.CFrame
				bullet.Velocity = bullet.CFrame:vectorToWorldSpace(Vector3.new(0, 1, 0)) * 2000
				bullet:SetNetworkOwner(game.Players:GetPlayerFromCharacter(seat.Occupant.Parent))
				
				bullet.Touched:connect(function(hit)
					if not hit:IsDescendantOf(plane) and not hit:IsDescendantOf(seat.Occupant.Parent) then
						local explosion = Instance.new("Explosion", game.Workspace)
						explosion.Position = bullet.Position
						explosion.BlastRadius = 4
						explosion.DestroyJointRadiusPercent = 0
						bullet:Destroy()
					end
				end)
				
				game.Debris:AddItem(bullet, 1)
			end
		end
	end
	wait(0.1)
end