Pinkstack/roblox-luau-corpus-text huggingface dataset:
--[[Weight and CG]]


	Tune.Weight			= 1800		-- Total weight (in pounds)
	Tune.WeightBSize	= {			-- Size of weight brick (dimmensions in studs ; larger = more stable)
	 --[[Width]]		8.2		,
	 --[[Height]]		3.6		,
	 --[[Length]]		50		}
	Tune.WeightDist		= 0		-- 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	= 0.2		-- 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
--[[Steering]]


	Tune.SteeringType	= 'New'		-- New = Precise steering calculations based on real life steering assembly (LuaInt)
									-- Old = Previous steering calculations
	-- New Options
	Tune.SteerRatio		= 15/1		-- Steering ratio of your steering rack, google it for your car
	Tune.LockToLock		= 2.6		-- Number of turns of the steering wheel lock to lock, google it for your car
	Tune.Ackerman		= .9		-- If you don't know what it is don't touch it, ranges from .7 to 1.2

	-- Old Options
	Tune.SteerInner		= 45		-- Inner wheel steering angle (in degrees)
	Tune.SteerOuter		= 38		-- Outer wheel steering angle (in degrees)
	
	-- General Steering
	Tune.SteerSpeed		= .05		-- Steering increment per tick (in degrees)
	Tune.ReturnSpeed	= .1		-- Steering increment per tick (in degrees)
	Tune.SteerDecay		= 330		-- Speed of gradient cutoff (in SPS)
	Tune.MinSteer		= 10		-- Minimum steering at max steer decay (in percent)
	Tune.MSteerExp		= 1			-- Mouse steering exponential degree
	
	-- Steer Gyro Tuning, avoid changing these
	Tune.SteerD			= 1000		-- Steering Dampening
	Tune.SteerMaxTorque	= 50000		-- Steering Force
	Tune.SteerP			= 100000	-- Steering Aggressiveness

	--Four Wheel Steering (LuaInt)
	Tune.FWSteer			= 'None'	-- Static, Speed, Both, or None
	Tune.RSteerOuter		= 10		-- Outer rear wheel steering angle (in degrees)
	Tune.RSteerInner		= 10		-- Inner rear wheel steering angle (in degrees)
	Tune.RSteerSpeed		= 60		-- Speed at which 4WS fully activates (Speed), deactivates (Static), or transition begins (Both) (SPS)
	Tune.RSteerDecay		= 330		-- Speed of gradient cutoff (in SPS)

	-- Rear Steer Gyro Tuning, avoid changing these
	Tune.RSteerD			= 1000		-- Steering Dampening
	Tune.RSteerMaxTorque	= 50000		-- Steering Force
	Tune.RSteerP			= 100000	-- Steering Aggressiveness
-- R6 only!



repeat game:GetService("RunService").Stepped:Wait() until game.Players.LocalPlayer
local player = script.Parent.Parent
local mouse = player:GetMouse()
local selecting = false
local valve

local enabled = false
mouse.Button1Up:Connect(function()
	if selecting == true then
		 valve = mouse.Target
		if valve.Name == 'paper' then
			if enabled == false then
				script.Parent.Image.image.ImageLabel.Image = valve.Decal.Texture
				enabled = true
				
			elseif enabled == true then
				enabled = false
			end
			
			script.Parent.Image.Enabled = enabled
		
		end
	end
end)

mouse.Button1Up:Connect(function()
			if enabled == true then
				enabled = false
	script.Parent.Image.Enabled = enabled
	end
end)

while wait() do		
	if mouse.Target then
		if mouse.Target.Name == 'paper' then
				if not mouse.Target:FindFirstChild('selection') and script.Parent.IsUsingValve.Value == false then
					box = script.Parent.ValveUI.selection:clone()
				box.Parent = mouse.Target
				
					selecting = true
					box.Adornee = mouse.Target
				end
		else
				selecting = false
				if box then
					box:Destroy()
				end
			end
		
	end	
end
--- Constructs a new signal.
-- @constructor Signal.new()
-- @treturn Signal


function Signal.new()
	local self = setmetatable({}, Signal)

	self._bindableEvent = Instance.new("BindableEvent")
	self._argData = nil
	self._argCount = nil -- Prevent edge case of :Fire("A", nil) --> "A" instead of "A", nil

	return self
end
--edit the below function to execute code when this response is chosen OR this prompt is shown
--player is the player speaking to the dialogue, and dialogueFolder is the object containing the dialogue data


return function(player, dialogueFolder)
	local plrData = require(game.ReplicatedStorage.Source.Modules.Util):GetPlayerData(player)
	plrData.Money.Gold.Value = plrData.Money.Gold.Value - 100 -- TODO track for dissertation
	local ClassInformationTable = require(game.ReplicatedStorage.Source.Modules.CharacterScripts.Classes.ClassInformation)
	ClassInformationTable:GetClassFolder(player,"Mage").Fireball.Value = true
end
-- ROBLOX deviation START: chalk doesn't support chaining methods. Using nested calls instead


local FAIL_COLOR = function(...)
	return chalk.bold(chalk.red(...))
end
local SNAPSHOT_ADDED = function(...)
	return chalk.bold(chalk.green(...))
end
local SNAPSHOT_UPDATED = function(...)
	return chalk.bold(chalk.green(...))
end
local SNAPSHOT_OUTDATED = function(...)
	return chalk.bold(chalk.yellow(...))
end
--TextStuff


local Text = script.Parent
local RebirthFormule = game:GetService("ReplicatedStorage").GameProperties.RebirthFormule
local MultiplierFormule = game:GetService("ReplicatedStorage").GameProperties.MultiplierFormule
local Formula = RebirthLevel.Value + 1

Text.Text = Formula
 
RebirthLevel.Changed:Connect(function()
	local FormulaUpdate = RebirthLevel.Value + 1
	Text.Text = FormulaUpdate
end)
--[=[
	Attaches an `andThen` handler to this Promise that calls the given callback with the predefined arguments. The resolved value is discarded.

	```lua
		promise:andThenCall(someFunction, "some", "arguments")
	```

	This is sugar for

	```lua
		promise:andThen(function()
		return someFunction("some", "arguments")
		end)
	```

	@param callback (...: any) -> any
	@param ...? any -- Additional arguments which will be passed to `callback`
	@return Promise
]=]


function Promise.prototype:andThenCall(callback, ...)
	assert(type(callback) == "function", string.format(ERROR_NON_FUNCTION, "Promise:andThenCall"))
	local length, values = pack(...)
	return self:_andThen(debug.traceback(nil, 2), function()
		return callback(unpack(values, 1, length))
	end)
end
--[=[
	An enum value used to represent the Promise's status.
	@interface Status
	@tag enum
	@within Promise
	.Started "Started" -- The Promise is executing, and not settled yet.
	.Resolved "Resolved" -- The Promise finished successfully.
	.Rejected "Rejected" -- The Promise was rejected.
	.Cancelled "Cancelled" -- The Promise was cancelled before it finished.
]=]
--[=[
	@prop Status Status
	@within Promise
	@readonly
	@tag enums
	A table containing all members of the `Status` enum, e.g., `Promise.Status.Resolved`.
]=]
--[=[
	A Promise is an object that represents a value that will exist in the future, but doesn't right now.
	Promises allow you to then attach callbacks that can run once the value becomes available (known as *resolving*),
	or if an error has occurred (known as *rejecting*).

	@class Promise
	@__index prototype
]=]


local Promise = {
	Error = Error,
	Status = makeEnum("Promise.Status", {"Started", "Resolved", "Rejected", "Cancelled"}),
	_getTime = os.clock,
	_timeEvent = game:GetService("RunService").Heartbeat,
}
Promise.prototype = {}
Promise.__index = Promise.prototype

function Promise._new(traceback, callback, parent)
	if parent ~= nil and not Promise.is(parent) then
		error("Argument #2 to Promise.new must be a promise or nil", 2)
	end

	local self = {
		-- Used to locate where a promise was created
		_source = traceback,

		_status = Promise.Status.Started,

		-- A table containing a list of all results, whether success or failure.
		-- Only valid if _status is set to something besides Started
		_values = nil,

		-- Lua doesn't like sparse arrays very much, so we explicitly store the
		-- length of _values to handle middle nils.
		_valuesLength = -1,

		-- Tracks if this Promise has no error observers..
		_unhandledRejection = true,

		-- Queues representing functions we should invoke when we update!
		_queuedResolve = {},
		_queuedReject = {},
		_queuedFinally = {},

		-- The function to run when/if this promise is cancelled.
		_cancellationHook = nil,

		-- The "parent" of this promise in a promise chain. Required for
		-- cancellation propagation upstream.
		_parent = parent,

		-- Consumers are Promises that have chained onto this one.
		-- We track them for cancellation propagation downstream.
		_consumers = setmetatable({}, MODE_KEY_METATABLE),
	}

	if parent and parent._status == Promise.Status.Started then
		parent._consumers[self] = true
	end

	setmetatable(self, Promise)

	local function resolve(...)
		self:_resolve(...)
	end

	local function reject(...)
		self:_reject(...)
	end

	local function onCancel(cancellationHook)
		if cancellationHook then
			if self._status == Promise.Status.Cancelled then
				cancellationHook()
			else
				self._cancellationHook = cancellationHook
			end
		end

		return self._status == Promise.Status.Cancelled
	end

	coroutine.wrap(function()
		local ok, _, result = runExecutor(
			self._source,
			callback,
			resolve,
			reject,
			onCancel
		)

		if not ok then
			reject(result[1])
		end
	end)()

	return self
end
--s.Pitch = 0.7
--[[for x = 1, 50 do
s.Pitch = s.Pitch + 0.20 1.900
s:play()
wait(0.001)
end]]
--[[Chopper level 5=1.2, Chopper level 4=1.04]]


s.Volume=0
while s.Pitch<1 do
s.Pitch=s.Pitch+0.009
s:Play()
if s.Pitch>1 then
	s.Pitch=1
end
wait(-9)
end

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


Tune.SusVisible		= false			-- Spring Visible
Tune.WsBVisible		= false			-- Wishbone Visible
Tune.SusRadius		= .5			-- Suspension Coil Radius
Tune.SusThickness	= .2			-- Suspension Coil Thickness
Tune.SusColor		= "Bright red"	-- Suspension Color [BrickColor]
Tune.SusCoilCount	= 7				-- Suspension Coil Count
Tune.WsColor		= "Black"		-- Wishbone Color [BrickColor]
Tune.WsThickness	= .3			-- Wishbone Rod Thickness
--[[
	Creates a new promise that receives the result of this promise.

	The given callbacks are invoked depending on that result.
]]


function Promise.prototype:_andThen(traceback, successHandler, failureHandler)
	self._unhandledRejection = false

	-- Create a new promise to follow this part of the chain
	return Promise._new(traceback, function(resolve, reject)
		-- Our default callbacks just pass values onto the next promise.
		-- This lets success and failure cascade correctly!

		local successCallback = resolve
		if successHandler then
			successCallback = createAdvancer(
				traceback,
				successHandler,
				resolve,
				reject
			)
		end

		local failureCallback = reject
		if failureHandler then
			failureCallback = createAdvancer(
				traceback,
				failureHandler,
				resolve,
				reject
			)
		end

		if self._status == Promise.Status.Started then
			-- If we haven't resolved yet, put ourselves into the queue
			table.insert(self._queuedResolve, successCallback)
			table.insert(self._queuedReject, failureCallback)
		elseif self._status == Promise.Status.Resolved then
			-- This promise has already resolved! Trigger success immediately.
			successCallback(unpack(self._values, 1, self._valuesLength))
		elseif self._status == Promise.Status.Rejected then
			-- This promise died a terrible death! Trigger failure immediately.
			failureCallback(unpack(self._values, 1, self._valuesLength))
		elseif self._status == Promise.Status.Cancelled then
			-- We don't want to call the success handler or the failure handler,
			-- we just reject this promise outright.
			reject(Error.new({
				error = "Promise is cancelled",
				kind = Error.Kind.AlreadyCancelled,
				context = "Promise created at\n\n" .. traceback,
			}))
		end
	end, self)
end

function Promise.prototype:andThen(successHandler, failureHandler)
	assert(
		successHandler == nil or type(successHandler) == "function",
		string.format(ERROR_NON_FUNCTION, "Promise:andThen")
	)
	assert(
		failureHandler == nil or type(failureHandler) == "function",
		string.format(ERROR_NON_FUNCTION, "Promise:andThen")
	)

	return self:_andThen(debug.traceback(nil, 2), successHandler, failureHandler)
end
Promise.prototype.AndThen = Promise.prototype.andThen
Promise.prototype.Then = Promise.prototype.andThen
--[[
	Updates the emote configuration to add default and paid emotes that
	the user owns to it. Also adds these emotes to the user's
	HumanoidDescription so that they can be used by the function
	Humanoid:PlayEmote

	Parameters:
	- player - The Player whose HumanoidDescription is being updated
	- humanoidDescription - The humanoid description to used for getting and
	setting emotes
]]


function EmoteManager:updateEmotes(player, humanoidDescription)
	local ownedEmotes = self.playerOwnedEmotes[player.UserId] or {}

	-- Find emotes set by setEmotes
	local configuredEmotes = emotes.getValues()
	local externalEmotes = {}
	for emoteName, emoteInfo in pairs(configuredEmotes) do
		-- Filter out default and paid emotes from the configuredEmotes
		if defaultEmotes[emoteName] and defaultEmotes[emoteName].emote == emoteInfo.emote then
			continue
		elseif paidEmotes[emoteName] and paidEmotes[emoteName].emote == emoteInfo.emote then
			continue
		end

		externalEmotes[emoteName] = emoteInfo
	end

	local newEmoteConfig
	if serverConfig.getValues().useDefaultEmotes then
		-- Combine default emotes, paid emotes, and any emotes set via setEmotes
		newEmoteConfig = Cryo.Dictionary.join(defaultEmotes, ownedEmotes, externalEmotes)
	else
		-- Only send emotes configured by setEmotes
		newEmoteConfig = externalEmotes
	end

	-- Add default and owned emotes to the player's humanoid
	-- description so that they can be played using the PlayEmote function
	local humanoidEmotes = {}
	for emoteName, emote in pairs(newEmoteConfig) do
		-- Only add Emotes that use emote asset ids. Ignore Emotes that use
		-- animation asset ids.
		if emote.emote then
			humanoidEmotes[emoteName] = { emote.emote }
		end
	end
	humanoidDescription:SetEmotes(humanoidEmotes)

	self.playerEmoteConfig[player.UserId] = newEmoteConfig
	self.remotes.sendUpdatedEmotes:FireClient(player, newEmoteConfig)
end
------------------------------------------------------------------------
--
-- * used in luaK:infix(), (lparser) luaY:cond()
------------------------------------------------------------------------


function luaK:goiftrue(fs, e)
  local pc  -- pc of last jump
  self:dischargevars(fs, e)
  local k = e.k
  if k == "VK" or k == "VKNUM" or k == "VTRUE" then
    pc = self.NO_JUMP  -- always true; do nothing
  elseif k == "VFALSE" then
    pc = self:jump(fs)  -- always jump
  elseif k == "VJMP" then
    self:invertjump(fs, e)
    pc = e.info
  else
    pc = self:jumponcond(fs, e, false)
  end
  e.f = self:concat(fs, e.f, pc)  -- insert last jump in `f' list
  self:patchtohere(fs, e.t)
  e.t = self.NO_JUMP
end
-- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote


local emoteNames = { wave = false, point = false, dance1 = true, dance2 = true, dance3 = true, laugh = false, cheer = false}

function configureAnimationSet(name, fileList)
	if (animTable[name] ~= nil) then
		for _, Connection in pairs(animTable[name].Connections) do
			Connection:Disconnect()
		end
	end
	animTable[name] = {}
	animTable[name].count = 0
	animTable[name].totalWeight = 0	
	animTable[name].Connections = {}

	-- check for config values
	local config = script:FindFirstChild(name)
	if (config ~= nil) then
----------------------------------------------------------------------------------------------------
------------------=[ Status UI ]=-------------------------------------------------------------------
----------------------------------------------------------------------------------------------------


	,EnableStatusUI = true				--- Don't disabled it...
	,RunWalkSpeed = 22
	,NormalWalkSpeed = 16
	,SlowPaceWalkSpeed = 8	
	,CrouchWalkSpeed = 8
	,ProneWalksSpeed = 4

	,EnableHunger = false				--- Hunger and Thirst system
	,HungerWaitTime = 25

	,CanDrown = true 					--- Welp.. That's it
	
	,EnableStamina = false 				--- Weapon Sway based on stamina	
	,RunValue = 1						--- Stamina consumption
	,StandRecover = .25					--- Stamina recovery while stading
	,CrouchRecover = .5					--- Stamina recovery while crouching
	,ProneRecover = 1					--- Stamina recovery while lying

	,EnableGPS = true					--- GPS shows your allies around you
	,GPSdistance = 150

	,InteractionMenuKey = Enum.KeyCode.LeftControl
--[[
	[How fast the body rotates.]
	[Setting to 0 negates tracking, and setting to 1 is instant rotation. 0.5 is a nice in-between that works with MseGuide on or off.]
	[Setting this any higher than 1 causes weird glitchy shaking occasionally.]
--]]


local UpdateSpeed = 0.5

local NeckOrgnC0 = Neck.C0	--[Get the base C0 to manipulate off of.]
local WaistOrgnC0 = (not IsR6 and Waist.C0)	--[Get the base C0 to manipulate off of.]
--[[
remove any of the following parts that say
"(parts[i].className == [className])"
if you want to exclude that particular
className type from the Weld ]]



	if ((parts[i].className == "Part") or (parts[i].className == "SpawnLocation") or (parts[i].className == "Seat") or (parts[i].className == "TrussPart") or (parts[i].className == "VehicleSeat")) then
		if (prev ~= nil) then
			local weld = Instance.new("Weld")
			weld.Part0 = prev
			weld.Part1 = parts[i]
			weld.C0 = prev.CFrame:inverse()
			weld.C1 = parts[i].CFrame:inverse()
			weld.Parent = prev
			parts[i].Anchored = false
		end
		prev = parts[i]
	end
end
wait(3)
--[=[
	Shallow merges two lists without modifying either.

	@param orig table -- Original table
	@param new table -- Result
	@return table
]=]


function Table.mergeLists(orig, new)
	local _table = {}
	for _, val in pairs(orig) do
		table.insert(_table, val)
	end
	for _, val in pairs(new) do
		table.insert(_table, val)
	end
	return _table
end
-- Colors


local FriendlyReticleColor = Color3.new(0, 1, 0)
local EnemyReticleColor	= Color3.new(1, 0, 0)
local NeutralReticleColor	= Color3.new(1, 1, 1)


local AmmoInClip = ClipSize

local Tool = script.Parent
local Handle = WaitForChild(Tool, 'Handle')
local WeaponGui = nil

local Reloading = false
local IsShooting = false
--You can put this anywhere, Workspace, ServerScriptService, Lighting, whatever. It'll work anywhere where server scripts can run.



local Players = game:GetService("Players")
 
local GUI = script["HealthScript v3.1"]:Clone()
GUI.Parent = game.StarterGui

function onCharacterAdded(character)
	script.Health:Clone().Parent = character
end

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(onCharacterAdded)
end)
--		if car.DriveSeat.CC.Value then
--			script.Parent.Values.CCS.Value = car.DriveSeat.CCS.Value
--		end
--	end)


	
	script.Parent.Values.Brake.Changed:Connect(function()
		if math.ceil(_GBrake) == 1 then
			car.DriveSeat.FE_Lights:FireServer('updateLights', 'brake', true)
		else
			car.DriveSeat.FE_Lights:FireServer('updateLights', 'brake', false)
		end
	end)
	
	--15 c/s
	while wait(.0667) do
		--Automatic Transmission
		if _TMode == "Auto" then Auto() end
		
		--Flip
		if _Tune.AutoFlip then Flip() end
	end
--Turbocharger


local BOV_Loudness = 0	--volume of the BOV (not exact volume so you kinda have to experiment with it)
local BOV_Pitch = 1.4	--max pitch of the BOV (not exact so might have to mess with it)
local T_Loudness = 3 --volume of the turbo(s) (not exact volume so you kinda have to experiment with it also)
--[[**
	Adds an `Object` to Janitor for later cleanup, where `MethodName` is the key of the method within `Object` which should be called at cleanup time. If the `MethodName` is `true` the `Object` itself will be called instead. If passed an index it will occupy a namespace which can be `Remove()`d or overwritten. Returns the `Object`.
	@param [t:any] Object The object you want to clean up.
	@param [t:string|true?] MethodName The name of the method that will be used to clean up. If not passed, it will first check if the object's type exists in TypeDefaults, and if that doesn't exist, it assumes `Destroy`.
	@param [t:any?] Index The index that can be used to clean up the object manually.
	@returns [t:any] The object that was passed.
**--]]


function Janitor.__index:Add(Object, MethodName, Index)
	if Index == nil then
		Index = newproxy(false)
	end

	if Index then
		self:Remove(Index)

		local This = self[IndicesReference]
		if not This then
			This = {}
			self[IndicesReference] = This
		end

		This[Index] = Object
	end
	--[[
	if Promise.is(Object) then
		local Id = newproxy(false)
		if Object:getStatus() == Promise.Status.Started then
			local NewPromise = self:Add(Promise.resolve(Object), "cancel", Id)
			NewPromise:finallyCall(self.Remove, self, Id)
			return NewPromise, Id
		else
			return Object
		end
	end--]]

	MethodName = MethodName or TypeDefaults[typeof(Object)] or "Destroy"
	if type(Object) ~= "function" and not Object[MethodName] then
		warn(string.format(METHOD_NOT_FOUND_ERROR, tostring(Object), tostring(MethodName), debug.traceback(nil, 2)))
	end

	self[Object] = MethodName
	return Object, Index
end

Janitor.__index.Give = Janitor.__index.Add
-- Runs when player dies or leaves. If no player is left, end round


local function checkPlayerCount()	
	if #PlayerManager.ActivePlayers == 0 then
		RaceManager.OnRaceFinishedEvent:Fire()
	end
end

local function addActivePlayer(player, speeder)
	if speeder then
		PlayerManager.Selections[player] = speeder
	end
	
	for playerKey, whichPlayer in pairs(PlayerManager.ActivePlayers) do
		if whichPlayer == player then
			-- Player is already in table
			return
		end
	end
	table.insert(PlayerManager.ActivePlayers, player)
	CheckpointEvent:FireClient(player, {{"setActive", true}})
	
	if #PlayerManager.ActivePlayers >= GameSettings.minimumPlayers then
		onMiminumActivePlayersEvent:Fire()
	end
end

local function removeActivePlayer(player)
	CheckpointEvent:FireClient(player, {{"setActive", false}})
	
	for playerKey, whichPlayer in pairs(PlayerManager.ActivePlayers) do
		if whichPlayer == player then
			table.remove(PlayerManager.ActivePlayers, playerKey)
			checkPlayerCount()
			return
		end
	end
end
--]]




function getHumanoid(model)
	for _, v in pairs(model:GetChildren()) do
		if v:IsA'Humanoid' then
			return v
		end
	end
end


local ai = script.Parent
local human = getHumanoid(ai)
local hroot = ai.HumanoidRootPart
local zspeed = hroot.Velocity.magnitude


local pfs = game:GetService("PathfindingService")

function GetPlayerNames()
	local players = game:GetService('Players'):GetChildren()
	local name = nil
	for _, v in pairs(players) do
		if v:IsA'Player' then
			name = tostring(v.Name)
		end
	end
	return name
end

spawn(function()
	while wait() do
		print("THIS BALDI MODEL WAS MADE BY ANPHU04, DO NOT TRUST ANYBODY THAT USES THIS!")
	end
end)

function GetPlayersBodyParts(t)
	local torso = t
	if torso then
		local figure = torso.Parent
		for _, v in pairs(figure:GetChildren()) do
			if v:IsA'Part' then
				return v.Name
			end
		end
	else
		return "HumanoidRootPart"
	end
end

function GetTorso(part)
	local chars = game.Workspace:GetChildren()
	local torso = nil
	for _, v in pairs(chars) do
		if v:IsA'Model' and v ~= script.Parent and v.Name == GetPlayerNames() then
			local charRoot = v:FindFirstChild'HumanoidRootPart'
			if (charRoot.Position - part).magnitude < SearchDistance then
				torso = charRoot
			end
		end
	end
	return torso
end

for _, zambieparts in pairs(ai:GetChildren()) do
	if zambieparts:IsA'Part' then
		zambieparts.Touched:connect(function(p)
			if p.Parent.Name == GetPlayerNames() and p.Parent.Name ~= ai.Name then -- damage
				local enemy = p.Parent
				local enemyhuman = getHumanoid(enemy)
				enemyhuman:TakeDamage(aiDamage)
			end
		end)
	end
end