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


script.Parent.OnServerEvent:Connect(function(p)
	wait(1)
	local Character = p.Character
	local Humanoid = Character.Humanoid
	local RootPart = Character.HumanoidRootPart
	local Slash1 = RS.Effects.Knives3:Clone()
	script.Attack:Play()
	script.Parent.Parent.Parent.Handle.Transparency = 0
	script.Parent.Parent.Parent.Handle.Part.Attachment.FX:Emit(15)
	Slash1.Parent = FX
	Slash1.CFrame = RootPart.CFrame * CFrame.new(0,0,-3)
	local BV = Instance.new("BodyVelocity",Slash1)
	BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
	BV.Velocity = p.Character.HumanoidRootPart.CFrame.LookVector * 70
	Slash1.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= p.Name then
			hit.Parent.Humanoid:TakeDamage(Damage)
			local HitEffect = Effects.HitFx.Attachment:Clone()
			local RootPart2 = hit.Parent.HumanoidRootPart
			HitEffect.Parent = RootPart2
			for _,Particles in pairs(HitEffect:GetDescendants()) do
				if Particles:IsA("ParticleEmitter") then
					Particles:Emit(Particles:GetAttribute("EmitCount"))
				end
			end
			HitEffect.Hit:Play()
			local vel = Instance.new("BodyVelocity", RootPart2)
			vel.MaxForce = Vector3.new(1,1,1) * 1000000;
			vel.Parent = RootPart2
			vel.Velocity = Vector3.new(1,1,1) * p.Character:WaitForChild("HumanoidRootPart").CFrame.LookVector * 0
			vel.Name  =  "SmallMoveVel"
			game.Debris:AddItem(vel,.3)
			Slash1:Destroy()
	end
		wait(1)
		BV:Destroy()
	for _,Particles in pairs(Slash1.Part.Parent:GetDescendants()) do
		if Particles:IsA("ParticleEmitter") then
			Particles.Enabled = false
		end
		end
		Slash1.PointLight.Enabled = false
end)
end)
-- Sets the mass of the specified part by adjusting its density so that all
-- speeders will have the same mass (using static _DENSITY and _VOLUME)


local function SetMass(part)
	local volume = part.Size.X * part.Size.Y * part.Size.Z
	local newDensity = _DENSITY * _VOLUME / volume
	
	-- Defaults except newDensity (density, friction, elasticity)
	part.CustomPhysicalProperties = PhysicalProperties.new(newDensity, 0.3, 0.5)
end -- SetMass()


local function HandleCollision(collidedPart, part, self)
	local RaceTrack = workspace:FindFirstChild("Racetrack")
	local EnvironmentAssets = workspace:FindFirstChild("Environment Assets")
	local Plants = EnvironmentAssets:FindFirstChild("Plants")
	
	if not collidedPart:IsDescendantOf(self.speeder) and not collidedPart:IsDescendantOf(RaceTrack)
	 and not collidedPart:IsDescendantOf(Plants) and not (collidedPart == workspace.SpeederSpawnLocation) 
	 and not PhysicsService:CollisionGroupContainsPart(_SPEEDEROBJECTSCOLLISIONGROUP, collidedPart) then
		-- Create particle effect
		local particle = Explosion:Clone()
		particle.CFrame = part.CFrame
		particle.Parent = workspace


		character:Destroy()
		ExplosionSound:Play()
		
		local planeGui = PlayerGui:FindFirstChild("DesktopGui") or 
			PlayerGui:FindFirstChild("ConsoleGui") or
			PlayerGui:FindFirstChild("MobileGui")
		if planeGui then
			planeGui.Enabled = false
		end
	
		local emitterChildren = particle:GetChildren()
	
		for _, child in pairs(emitterChildren) do 
			-- If the child is a particle, then cause it to emit
			if child:IsA("ParticleEmitter") then
				child:Emit(10) 
			end
		end


		-- Destroy particle after PARTICLE_DURATION seconds
		spawn(function() 
			wait(PARTICLE_DURATION) 
			particle:Destroy() 
		end)
		-- Convert speeder to player
		spawn(function() 
			wait(2)
			PlayerConverter:SpeederToPlayer(false)
		end)	
	end
end -- handleCollisions()


local function SetupCollisionDetection(parent, self)
	for _,part in pairs(parent:GetChildren()) do
		if (part:IsA("BasePart") or part:IsA("MeshPart")) and part.Name ~= "Head" and 
			part.Name ~= "UpperTorso" and part.Name ~= "Arrow" then
			part.Touched:Connect(function(collidedPart) HandleCollision(collidedPart, part, self) end)
			SetupCollisionDetection(part, self)
		end
	end
end -- setupCollisionDetection()
-- NOTE: To me, this appears a bit 'hackish' so I can't
-- promise that it will always work!





local noJump = script.NoJump:Clone()
	script.NoJump:Destroy()


function CharacterSpawned(char)
	local noJ = noJump:Clone()
	noJ.Parent = char
	Delay(0.2, function()
		noJ.Disabled = false
	end)
end

function PlayerEntered(player)
	player.CharacterAdded:connect(CharacterSpawned)
end

for _,v in pairs(game.Players:GetPlayers()) do PlayerEntered(v) end
game.Players.PlayerAdded:connect(PlayerEntered)
--[=[
	Cleans up the service bag and all services that have been
	initialized in the service bag.
]=]


function ServiceBag:Destroy()
	local super = getmetatable(ServiceBag)

	self._destroying:Fire()

	local services = self._services
	local key, service = next(services)
	while service ~= nil do
		services[key] = nil
		if service.Destroy then
			service:Destroy()
		end
		key, service = next(services)
	end

	super.Destroy(self)
end

return ServiceBag
--// All global vars will be wiped/replaced except script



return function(data, env)
	if env then
		setfenv(1, env)
	end
	
	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
--Allows users to do /w displayName along with /w userName, only works if PlayerDisplayNamesEnabled is 'true'


module.WhisperByDisplayName = false

local ChangedEvent = Instance.new("BindableEvent")

local proxyTable = setmetatable({},
{
	__index = function(tbl, index)
		return module[index]
	end,
	__newindex = function(tbl, index, value)
		module[index] = value
		ChangedEvent:Fire(index, value)
	end,
})

rawset(proxyTable, "SettingsChanged", ChangedEvent.Event)

return proxyTable
--RPM
--RPM = 11000 / 100000 = 0.1, RPM = 1000 / 100000 = 0.01 * 4 = 0.04


Values.Values.RPM.Changed:connect(function()
	Throttle = Values.Values.Throttle.Value
	CurrentGear = Values.Values.Gear.Value
	CurrentRPM = Values.Values.RPM.Value
	if Throttle == 1 then
		active = true
		if CPSI < PSI then 
			if Turbos == "Single" then
				if TurboSize == "Small" then
					CPSI = CPSI + (CurrentRPM / 75000) * 4
					wait(0.1)
					Values.Values.PSI.Value = CPSI * 8
					Values.Values.APSI.Value = CPSI
				end
				if TurboSize == "Medium" then
					CPSI = CPSI + (CurrentRPM / 100000) * 4
					wait(0.1)
					Values.Values.PSI.Value = CPSI * 10
					Values.Values.APSI.Value = CPSI
				end
				if TurboSize == "Large" then
					CPSI = CPSI + (CurrentRPM / 125000) * 4
					wait(0.1)
					Values.Values.PSI.Value = CPSI * 12
					Values.Values.APSI.Value = CPSI
				end
			elseif Turbos == "Twin" then
				if TurboSize == "Small" then
					CPSI = CPSI + (CurrentRPM / 75000) * 4
					wait(0.05)
					Values.Values.PSI.Value = CPSI * 8
					Values.Values.APSI.Value = CPSI
				end
				if TurboSize == "Medium" then
					CPSI = CPSI + (CurrentRPM / 100000) * 4
					wait(0.05)
					Values.Values.PSI.Value = CPSI * 10
					Values.Values.APSI.Value = CPSI
				end
				if TurboSize == "Large" then
					CPSI = CPSI + (CurrentRPM / 125000) * 4
					wait(0.05)
					Values.Values.PSI.Value = CPSI * 12
					Values.Values.APSI.Value = CPSI
				end	
			end
		end
		if CurrentRPM > (_Tune.Redline - 500) and TwoStep == true and boom == true  then
			boom = false
				if car.Body.Exhaust.E1.S.IsPlaying then
				else
				local i = math.random(1,4)
				i = math.ceil(i)
				while i >= 1 do
				car.Body.Exhaust.E2.S:Play()
				car.Body.Exhaust.E1.Afterburn.Enabled = true
				car.Body.Exhaust.E2.Afterburn.Enabled = true
				wait(math.random(0.2,.3))
				car.Body.Exhaust.E1.Afterburn.Enabled = false
				car.Body.Exhaust.E2.Afterburn.Enabled = false
				i= i - 1
				end
				wait(0.5)
				boom = true
				end
				end
	end
			if Throttle <= 0.01 and active == true and Valve == "BOV" then
				active = false
				CPSI = 0
				if TurboSize == "Large" then
					Values.Values.PSI.Value = CPSI * 12
				elseif TurboSize == "Medium" then
					Values.Values.PSI.Value = CPSI * 10
				elseif TurboSize == "Small" then
					Values.Values.PSI.Value = CPSI * 8
				end	
				Values.Values.APSI.Value = CPSI
				if BOV.IsPlaying then		
				else
				BOV:Play()
				end
			end
			if Throttle <= 0.01 and Valve == "Bleed" then
				if CPSI > 0 then
				CPSI = CPSI - 0.1
				wait(0.05)
				end
				if TurboSize == "Large" then
					Values.Values.PSI.Value = CPSI * 12
				elseif TurboSize == "Medium" then
					Values.Values.PSI.Value = CPSI * 10
				elseif TurboSize == "Small" then
					Values.Values.PSI.Value = CPSI * 8
				end				
				Values.Values.APSI.Value = CPSI
				if active == true then
				if BOV.IsPlaying then		
				else
				BOV:Play()
				active = false
				end
				end
			end
		end
)
if boom == false then wait(math.random(1)) boom = true end
--[[
	Assert that the expectation value is the given type.

	expect(5).to.be.a("number")
]]


function Expectation:a(typeName)
	local result = (type(self.value) == typeName) == self.successCondition

	local message = formatMessage(self.successCondition,
		("Expected value of type %q, got value %q of type %s"):format(
			typeName,
			tostring(self.value),
			type(self.value)
		),
		("Expected value not of type %q, got value %q of type %s"):format(
			typeName,
			tostring(self.value),
			type(self.value)
		)
	)

	assertLevel(result, message, 3)
	self:_resetModifiers()

	return self
end
--[[Output Scaling Factor]]



	local hpScaling = _Tune.WeightScaling*10
	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
--[=[
	Gets an index by value, returning `nil` if no index is found.
	@param haystack table -- To search in
	@param needle Value to search for
	@return The index of the value, if found
	@return nil -- if not found
]=]


function Table.getIndex(haystack, needle)
	assert(needle ~= nil, "Needle cannot be nil")

	for index, item in pairs(haystack) do
		if needle == item then
			return index
		end
	end
	return nil
end
--local INTERNAL_MATCHER_FLAG = JestMatchersObject.INTERNAL_MATCHER_FLAG


local getMatchers = JestMatchersObject.getMatchers
local getState = JestMatchersObject.getState
local setMatchers = JestMatchersObject.setMatchers
local setState = JestMatchersObject.setState
local matchers = require(CurrentModule.matchers)
local spyMatchers = require(CurrentModule.spyMatchers)
local toThrowMatchers = require(CurrentModule.toThrowMatchers).matchers

local Types = require(CurrentModule.types)
type AsyncExpectationResult = Types.AsyncExpectationResult
type Expect = Types.Expect_
type ExpectationResult = Types.ExpectationResult
type JestMatcherState = Types.MatcherState
type MatcherInterface<R> = Types.Matchers_<R>
type MatchersObject<T> = Types.MatchersObject<T>
type PromiseMatcherFn = Types.PromiseMatcherFn
type RawMatcherFn = Types.RawMatcherFn_
type SyncExpectationResult = Types.SyncExpectationResult
type ThrowingMatcherFn = Types.ThrowingMatcherFn

local utils = require(CurrentModule.utils)
local iterableEquality = utils.iterableEquality
local subsetEquality = utils.subsetEquality
--!strict
--[=[
	@function map
	@within Array

	@param array {T} -- The array to map.
	@param mapper (value: T, index: number, array: {T}) -> U? -- The mapper function.
	@return {U} -- The mapped array.

	Maps the array using the mapper function.

	```lua
	local array = { 1, 2, 3 }

	local new = Map(array, function(value, index)
		return value * 2
	end) -- { 2, 4, 6 }
	```
]=]


local function map<T, U>(array: { T }, mapper: (value: T, index: number, array: { T }) -> U?): { U }
	local mapped = {}

	for index, value in ipairs(array) do
		local mappedValue = mapper(value, index, array)

		if mappedValue ~= nil then
			table.insert(mapped, mappedValue)
		end
	end

	return mapped
end

return map
--[[ if CC == 1 then

blood.CanCollide = false

elseif CC == 2 then

blood.CanCollide = true

end ]]

--  IF YOU WANT YOUR BLOOD TO SOMETIME BE CANCOLLIDE TRUE, THEN REMOVE THE --[[ AND ]]--
if script.Parent:FindFirstChild("Torso") ~= nil then
	blood.Position = script.Parent.Torso.Position
	blood.Parent = game.Workspace
end

end

human = script.Parent:findFirstChild("Humanoid")
health = human.Health

while true do

if human.Health < health then

howmuch = math.random(7,20)
health = human.Health

for i = 1 , howmuch do

MakeBlood()

end

end

wait(0.1)
end
--// Setting things up


for ind, loc in pairs({
	_G = _G;
	game = game;
	spawn = spawn;
	script = script;
	getfenv = getfenv;
	setfenv = setfenv;
	workspace = workspace;
	getmetatable = getmetatable;
	setmetatable = setmetatable;
	loadstring = loadstring;
	coroutine = coroutine;
	rawequal = rawequal;
	typeof = typeof;
	print = print;
	math = math;
	warn = warn;
	error = error;
	assert = assert;
	pcall = pcall;
	xpcall = xpcall;
	select = select;
	rawset = rawset;
	rawget = rawget;
	ipairs = ipairs;
	pairs = pairs;
	next = next;
	Rect = Rect;
	Axes = Axes;
	os = os;
	time = time;
	Faces = Faces;
	unpack = unpack;
	string = string;
	Color3 = Color3;
	newproxy = newproxy;
	tostring = tostring;
	tonumber = tonumber;
	Instance = Instance;
	TweenInfo = TweenInfo;
	BrickColor = BrickColor;
	NumberRange = NumberRange;
	ColorSequence = ColorSequence;
	NumberSequence = NumberSequence;
	ColorSequenceKeypoint = ColorSequenceKeypoint;
	NumberSequenceKeypoint = NumberSequenceKeypoint;
	PhysicalProperties = PhysicalProperties;
	Region3int16 = Region3int16;
	Vector3int16 = Vector3int16;
	require = require;
	table = table;
	type = type;
	wait = wait;
	Enum = Enum;
	UDim = UDim;
	UDim2 = UDim2;
	Vector2 = Vector2;
	Vector3 = Vector3;
	Region3 = Region3;
	CFrame = CFrame;
	Ray = Ray;
	task = task;
	service = service
	})
do
	locals[ind] = loc
end
--Rescripted by Luckymaxer



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

Players = game:GetService("Players")

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

Gravity = 500
JumpHeightPercentage = 0.1

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)
--tone hz


elseif sv.Value==6 then
while s.Pitch<1.1 do
s.Pitch=s.Pitch+0.012
s:Play()
if s.Pitch>1.1 then
	s.Pitch=1.1
end
wait(-9)
end

while true do
for x = 1, 500 do
s:play()
wait(-9)
end
wait()
end
--theRal



worker = false
part = script.Parent

function onTouch(hit)
	local human = hit.Parent:FindFirstChild("Humanoid")
	if (human ~= nil) and (worker == false) then
		print ("Success")
		worker = true
		wait(.1)
		local pant = hit.Parent:GetChildren()
		for i=1,#pant do
		if (pant[i].className == "Pants") then
			pant[i].PantsTemplate = ""
			end
		end
		local shirt = hit.Parent:GetChildren()
		for i=1,#shirt do
		if (shirt[i].className == "Shirt") then
			shirt[i].ShirtTemplate = ""
			wait(1)
			worker = false
			end
		end
	end
end

script.Parent.Touched:connect(onTouch)
--//////// DO NOT EDIT BELOW UNLESS YOU KNOW WHAT YOU'RE DOING \\\\\\\\\\\\\\\\\\\\\\\\\





local uis = game:GetService("UserInputService")
local runservice = game:GetService("RunService")
local tweenservice = game:GetService("TweenService")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local camera = workspace.CurrentCamera
repeat runservice.Heartbeat:Wait() until script.Parent:IsA("Model") -- yield until character
local character = player.Character
local rootpart = character:WaitForChild("HumanoidRootPart")
local humanoid = character:WaitForChild("Humanoid")
local aimoffset = script:WaitForChild("AimOffset") -- a property for other scripts to use to influence the viewmodel offset (such as a gun aim system)
local torso
local roothip
local lowertorso
local oldc0
local leftshoulder
local rightshoulder
local larm
local rarm
local armparts = {}
local rigtype = nil

local isrunning = false
local armsvisible = true -- whether the arms are visible in first person
local armtransparency = firstperson_arm_transparency
local isfirstperson = false
local sway = Vector3.new(0,0,0)
local walksway = CFrame.new(0,0,0)
local strafesway = CFrame.Angles(0,0,0)
local jumpsway = CFrame.new(0,0,0)
local jumpswaygoal = Instance.new("CFrameValue")
--	carSeat.DLock:Play()
--	carSeat.Seatlock.Value = lock
--	carSeat.Parent.Body.GS.A.SingleMode.Value = lock
--	carSeat.Parent.Body.GS.B.SingleMode.Value = lock
--	carSeat.Parent.Body.GS.C.SingleMode.Value = lock
--	carSeat.Parent.Body.GS.D.SingleMode.Value = lock
--	carSeat.Parent.Body.GS.E.SingleMode.Value = lock
--	carSeat.Parent.Misc.L.Door.H.ClickDetector.MaxActivationDistance = dr
--	carSeat.Parent.Misc.R.Door.H.ClickDetector.MaxActivationDistance = dr
--	carSeat.Parent.Misc.L.Door.SS.Motor.DesiredAngle = 0
--	carSeat.Parent.Misc.R.Door.SS.Motor.DesiredAngle = 0


end

F.setdist = function(v)
	carSeat.Parent.Body.MP.Sound.MaxDistance = v
	if v < 75 then
		carSeat.Parent.Body.MP.Sound.RollOffMode = "LinearSquare"
	else
		carSeat.Parent.Body.MP.Sound.RollOffMode = "Inverse"
	end
end

F.volumeup = function(VolUp)
	carSeat.Parent.Body.MP.Sound.Volume = carSeat.Parent.Body.MP.Sound.Volume + 1
-- Module Scripts


local ModuleScripts = ServerScriptService:FindFirstChild("ModuleScripts")
local RaceModules = ModuleScripts:FindFirstChild("RaceModules")
local ReplicatedModuleScripts = ReplicatedStorage:FindFirstChild("ModuleScripts")
local PlayerManager = require(RaceModules:FindFirstChild("PlayerManager"))
local GameSettings = require(RaceModules:FindFirstChild("GameSettings"))
local DisplayManager = require(RaceModules:FindFirstChild("DisplayManager"))
local LeaderboardManager = require(RaceModules:FindFirstChild("LeaderboardManager"))
local Timer = require(RaceModules:FindFirstChild("Timer"))
local RaceManager = require(ReplicatedModuleScripts:FindFirstChild("RaceManager"))
--Script


feedbackMain.CharactersLeft.Text = maxCharacters - #feedbackMain.InputBox.Input.Text
feedbackMain.InputBox.Input.Changed:Connect(function()
	feedbackMain.CharactersLeft.Text = maxCharacters - #feedbackMain.InputBox.Input.Text
	if maxCharacters - #feedbackMain.InputBox.Input.Text < 0 then
	else
	end
end)

local db = false
feedbackMain.SendButton.MouseButton1Click:Connect(function()
	if not db and maxCharacters - #feedbackMain.InputBox.Input.Text >= 0 then
		db = true
		local msg = feedbackMain.InputBox.Input.Text
		feedbackMain.InputBox.Input.Text = "Wait a moment..."
		local response = game.ReplicatedStorage.FilteringFunction:InvokeServer(msg)
		feedbackMain.InputBox.Input.Text = response
		wait(5)
		if feedbackMain.InputBox.Input.Text == response then
			feedbackMain.InputBox.Input.Text = "Type here."
		end
		db = false
	end
end)

script.Parent.Button.MouseButton1Click:Connect(function()
	open = not open
	if open then
		feedbackMain.Visible = true
	else
		feedbackMain.Visible = false
	end
end)
--[[ @brief Proportionally modifies all numbers in an array so the sum is 1.
     @example Normalize({1, 2, 3}) = {1/6, 2/6, 3/6};
     @param t The array to normalize.
     @return t The normalized array. This will be the same as t.
--]]


function module.Normalize(t)
	local sum = module.Sum(t);
	if sum~=0 then
		for i, v in pairs(t) do
			t[i] = v/sum;
		end
	end
	return t;
end
--// initialize opening/closing spectate //--


script.Parent.Parent.SpectateButton.Spectate.MouseButton1Down:connect(function(click)
	if script.Parent.GuiActive.Value == false then
		script.Parent.GuiActive.Value = true
		script.Parent.Parent.ChangePlayer.Visible = true
	elseif script.Parent.GuiActive.Value == true then
		resetGui()
	end
end)
--[=[
	@within TableUtil
	@function Filter
	@param tbl table
	@param predicate (value: any, key: any, tbl: table) -> keep: boolean
	@return table

	Performs a filter operation against the given table, which can be used to
	filter out unwanted values from the table.

	For example:

	```lua
	local t = {A = 10, B = 20, C = 30}
	local t2 = TableUtil.Filter(t, function(value, key)
		return value > 15
	end)
	print(t2) --> {B = 40, C = 60}
	```
]=]


local function Filter<T>(t: { T }, predicate: (T, any, { T }) -> boolean): { T }
	assert(type(t) == "table", "First argument must be a table")
	assert(type(predicate) == "function", "Second argument must be a function")
	local newT = table.create(#t)
	if #t > 0 then
		local n = 0
		for i, v in t do
			if predicate(v, i, t) then
				n += 1
				newT[n] = v
			end
		end
	else
		for k, v in t do
			if predicate(v, k, t) then
				newT[k] = v
			end
		end
	end
	return newT
end