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



local List = {}

function List.Create(list, max, fillDirection, padding, instanceFunc)
	max = max or math.huge
	padding = padding or UDim.new(0, 0)
	fillDirection = fillDirection or Enum.FillDirection.Vertical
	instanceFunc = instanceFunc or defaultButton

	local nList = #list
	local dList = 1 / nList
	
	local isVertical = (fillDirection == Enum.FillDirection.Vertical)
	
	local listFrame = Instance.new("Frame")
	listFrame.Name = "ListFrame"
	listFrame.BorderSizePixel = 0 
	
	local scrollFrame = Instance.new("ScrollingFrame")
	scrollFrame.Name = "ScrollFrame"
	scrollFrame.BackgroundTransparency = 1
	scrollFrame.BorderSizePixel = 0
	scrollFrame.Size = UDim2.new(1, 0, 1, 0)
	
	local canvasSize = nil	
	local elementSize = nil
	local extraPosition = nil
	
	local adj = (nList - 1) / nList
	local scale = padding.Scale * adj
	local offset = padding.Offset * adj
	
	if (isVertical) then
		canvasSize = UDim2.new(0, 0, nList / max, 0) 
		elementSize = UDim2.new(1, 0, dList - scale, -offset)
	else
		canvasSize = UDim2.new(nList / max , 0, 0, 0)
		elementSize = UDim2.new(dList - scale, -offset, 1, 0)
	end
	
	scrollFrame.CanvasSize = canvasSize
	
	local items = {}
	for i, option in ipairs(list) do
		local item = instanceFunc(i, option)
		item.LayoutOrder = i
		item.Size = elementSize
		item.Position = UDim2.new(0, 0, (i-1)*dList, 0)
		
		if (isVertical) then
			item.Position = item.Position + UDim2.new(0, 0, padding.Scale/nList*(i-1), padding.Offset/nList*(i-1))
		else
			item.Position = item.Position + UDim2.new(padding.Scale/nList*(i-1), padding.Offset/nList*(i-1), 0, 0)
		end
		
		items[i] = item
		item.Parent = scrollFrame
	end
	
	listFrame.BackgroundTransparency = items[1].BackgroundTransparency
	listFrame.BackgroundColor3 = items[1].BackgroundColor3
	scrollFrame.Parent = listFrame
	
	return listFrame	
end
-- Setting these here so the functions above can self-reference just by name:


MockDataStoreUtils.logMethod = logMethod
MockDataStoreUtils.deepcopy = deepcopy
MockDataStoreUtils.scanValidity = scanValidity
MockDataStoreUtils.getStringPath = getStringPath
MockDataStoreUtils.importPairsFromTable = importPairsFromTable
MockDataStoreUtils.prepareDataStoresForExport = prepareDataStoresForExport
MockDataStoreUtils.preprocessKey = preprocessKey
MockDataStoreUtils.accurateWait = accurateWait
MockDataStoreUtils.simulateYield = simulateYield
MockDataStoreUtils.simulateErrorCheck = simulateErrorCheck

return MockDataStoreUtils
--[=[
	Takes in a data type, and returns it in array form.
	
	```lua
	local str = "Test"
	
	print(TableKit.From(str)) -- prints ("T", "e", "s", t")
	```

	@within TableKit
	@param value unknown
	@return { [number]: unknown }
]=]


function TableKit.From(value: any): { any }
	local valueType = typeof(value)
	if valueType == "string" then
		return string.split(value, "")
	elseif valueType == "Color3" then
		return { value.R, value.G, value.B }
	elseif valueType == "Vector2" then
		return { value.X, value.Y }
	elseif valueType == "Vector3" then
		return { value.X, value.Y, value.Z }
	elseif valueType == "NumberSequence" then
		return value.Keypoints
	elseif valueType == "Vector3int16" then
		return { value.X, value.Y, value.Z }
	elseif valueType == "Vector2int16" then
		return { value.X, value.Y }
	else
		return { value }
	end
end
--!strict
-- upstream: https://github.com/facebook/react/blob/6faf6f5eb1705eef39a1d762d6ee381930f36775/packages/shared/objectIs.js
--[[*
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @flow
 ]]
--Change sound id to the id you want to play




debounce = false

script.Parent.Touched:connect(function(hit)
if not debounce then
debounce = true
if(hit.Parent:FindFirstChild("Humanoid")~=nil)then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local sound = script.Parent.Sound:Clone()
sound.Parent = player.PlayerGui
sound:Play()
wait(2.5)--change to how long before the sound plays again after retouching it
end
debounce = false
end
end)
--References to bindable events that act similarly to the original mouse 


Mouse.LeftClick = leftClick.Event 
Mouse.RightClick = rightClick.Event

function Mouse.GetUnitRay() : Ray
	--Get position of mouse on screen 
	local x : number, y : number = UserInputService:GetMouseLocation().X, UserInputService:GetMouseLocation().Y

	--Convert that to a unit ray pointing towards the camera CFrame 
	local ray : Ray = cam:ViewportPointToRay(x, y)	
	
	return ray 
end

function Mouse.Raycast(rayParams : RaycastParams?) : (RaycastResult?, Ray) 
	local unitRay : Ray = Mouse.GetUnitRay()
	
	--Raycast from the origin to max dist 
	local result : RaycastResult? = workspace:Raycast(unitRay.Origin, unitRay.Direction * MAX_DISTANCE, rayParams)
	
	--Give them the RaycastResult and Unit Ray, if they need it  
	return result, unitRay
end

function Mouse.GetPosition(rayParams : RaycastParams?) : Vector3
    --Get the current Mouse Position, either as a raycastResult or Ray 
    local raycast : RaycastResult?, unitRay : Ray = Mouse.Raycast(rayParams)

    --Return the appropriate value 
	if raycast then 
		--The raycast was successful, so we can just get the position 
        return raycast.Position 
	elseif unitRay then 
		--Raycast was not successful, we need to manually calculate the intended position 
        return unitRay.Origin + unitRay.Direction * MAX_DISTANCE
    end
end

function Mouse.GetTarget(rayParams : RaycastParams?) : Instance?
	--Call the raycast, forwarding the rayParams object 
	local raycast : RaycastResult, unitRay : Ray = Mouse.Raycast(rayParams)
	
	--Give them target if it exists 
    return raycast and raycast.Instance
end

function Mouse._OnInput(obj : InputObject)
    if obj.UserInputType == Enum.UserInputType.MouseButton1 then 
        leftClick:Fire(obj.UserInputState)
    elseif obj.UserInputType == Enum.UserInputType.MouseButton2 then 
        rightClick:Fire(obj.UserInputState)
    end  
end

UserInputService.InputBegan:Connect(Mouse._OnInput)
UserInputService.InputEnded:Connect(Mouse._OnInput)

return Mouse
-- @specs https://material.io/guidelines/motion/duration-easing.html#duration-easing-natural-easing-curves


local Sharp = Bezier(0.4, 0, 0.6, 1)
local Standard = Bezier(0.4, 0, 0.2, 1) -- used for moving.
local Acceleration = Bezier(0.4, 0, 1, 1) -- used for exiting.
local Deceleration = Bezier(0, 0, 0.2, 1) -- used for entering.
----[[ Color Settings ]]


module.BackGroundColor = Color3.fromRGB(72, 0, 32)
module.DefaultMessageColor = Color3.new(1, 1, 1)
module.DefaultNameColor = Color3.new(1, 1, 1)
module.ChatBarBackGroundColor = Color3.fromRGB(72, 0, 32)
module.ChatBarBoxColor = Color3.new(1, 1, 1)
module.ChatBarTextColor = Color3.fromRGB(97, 19, 37)
module.ChannelsTabUnselectedColor = Color3.new(0, 0, 0)
module.ChannelsTabSelectedColor = Color3.new(30/255, 30/255, 30/255)
module.DefaultChannelNameColor = Color3.fromRGB(35, 76, 142)
module.WhisperChannelNameColor = Color3.fromRGB(102, 14, 102)
module.ErrorMessageTextColor = Color3.fromRGB(245, 50, 50)
-- Load and configure the animations


local attackIdleAnimation = maid.humanoid:LoadAnimation(maid.instance.Animations.AttackIdleAnimation)
attackIdleAnimation.Looped = true
attackIdleAnimation.Priority = Enum.AnimationPriority.Action
maid.attackIdleAnimation = attackIdleAnimation

local attackAnimation = maid.humanoid:LoadAnimation(maid.instance.Animations.AttackAnimation)
attackAnimation.Looped = false
attackAnimation.Priority = Enum.AnimationPriority.Action
maid.attackAnimation = attackAnimation

local reloadAnimation = maid.humanoid:LoadAnimation(maid.instance.Animations.ReloadAnimation)
reloadAnimation.Looped = false
reloadAnimation.Priority = Enum.AnimationPriority.Action
maid.reloadAnimation = reloadAnimation
--[=[
	Returns a function that can be used to load modules relative
	to the script specified.

	```lua
	local require = require(script.Parent.loader).load(script)

	local maid = require("Maid")
	```

	@function load
	@param script Script -- The script to load dependencies for.
	@return (moduleReference: ModuleReference) -> any
	@within Loader
]=]


local function handleLoad(moduleScript)
	assert(typeof(moduleScript) == "Instance", "Bad moduleScript")

	return loader:GetLoader(moduleScript)
end

return setmetatable({
	load = handleLoad;
	bootstrapGame = bootstrapGame;
	bootstrapPlugin = bootstrapPlugin;
}, metatable)
--------------------[ KEYBOARD FUNCTIONS ]--------------------------------------------



function KeyPress(key)
	if key then
		if Active then
			key = string.lower(key)
			if key == "c" then
				if Stance == 2 then
					print("Crouch")
					Crouch()
				end
			else
				if key == "x" then
					if Stance == 1 then
						print("Stand")
						Stand()
					end
				end
			end
		end
	end
end


script.Parent.Equipped:connect(function()
	Active = true
	mouse.KeyDown:connect(KeyPress)
end)

script.Parent.Unequipped:connect(function()
	Active = false
	Stand()
end)
--PlayerClick


ClickDetector.MouseClick:Connect(function()
	if Ready == true then
		if Open == false then
			Ready = false
			Open = true
			Handle.TargetAngle = 90
			OpenSound:Play()
			OpenTween:Play()
			wait(.5)
			Ready = true
		elseif Open == true then
			Ready = false
			Open = false
			Handle.TargetAngle = 0
			CloseSound:Play()
			CloseTween:Play()
			wait(.5)
			Ready = true
		end
	end
end)
-- Create the level loader


local function loadLevel(level)
	-- Clear the current level
	for _, enemy in pairs(gameState.enemies) do
		enemy:Destroy()
	end

	-- Create the new level
	local levelData = ReplicatedStorage.Levels[level]
	for _, enemyData in pairs(levelData.Enemies) do
		local enemy = game.ServerStorage.Enemies[enemyData.Name]:Clone()
		enemy.Parent = workspace
		gameState.enemies[#gameState.enemies + 1] = enemy
	end

	-- Set the new level
	gameState.level = level
end
--Don't modify this script unless you really know what you're doing.



local WaitFor = (function(parent, child_name)
	local found = parent:FindFirstChild(child_name)
	while found == nil do
		parent.ChildAdded:wait()
		found = parent:FindFirstChild(child_name)
		if found then break end
	end
	return found
end)

local last = { neckC1 = nil, rshoC0 = nil, lshoC0 = nil, rhipC0 = nil, lhipC0 = nil }

local ApplyModifications = (function(weld, char)
	local torso = WaitFor(char, "Torso")
	local neck = WaitFor(torso, "Neck")
	local rsho = WaitFor(torso, "Right Shoulder")
	local lsho = WaitFor(torso, "Left Shoulder")
	local rhip = WaitFor(torso, "Right Hip")
	local lhip = WaitFor(torso, "Left Hip")

	local config = script.Parent.Configuration
	local head_ang = config["Head Angle"].Value
	local legs_ang = config["Legs Angle"].Value
	local arms_ang = config["Arms Angle"].Value
	local sit_ang  = config["Sitting Angle"].Value
	local sit_pos  = config["Sitting Position"].Value

	--First adjust sitting position and angle
	--Add 90 to the angle because that's what most people will be expecting.
	--weld.C1 = weld.C1 * CFrame.fromEulerAnglesXYZ(math.rad((sit_ang) + 90), 0, 0)
	
	--weld.C0 = CFrame.new(sit_pos)
	weld.C0 = weld.C0 * CFrame.new(0, 1, 0)

	last.neckC1 = neck.C1
	last.rshoC0 = rsho.C0
	last.lshoC0 = lsho.C0
	last.rhipC0 = rhip.C0
	last.lhipC0 = lhip.C0

	--Now adjust the neck angle.
	neck.C1 = neck.C1 * CFrame.fromEulerAnglesXYZ(math.rad(head_ang), 0, 0)
	

	--Now adjust the arms angle.
	rsho.C0 = rsho.C0 * CFrame.fromEulerAnglesXYZ(0, 0, 0)
	lsho.C0 = lsho.C0 * CFrame.fromEulerAnglesXYZ(0,math.rad(arms_ang), 0.3)
	lsho.C0 = lsho.C0 * CFrame.new(-1,0, -0.5)

	--Now the legs
	rhip.C0 = rhip.C0 * CFrame.fromEulerAnglesXYZ(0, 0, math.rad(legs_ang))
	lhip.C0 = lhip.C0 * CFrame.fromEulerAnglesXYZ(0, 0, math.rad(-legs_ang))
end)

local RevertModifications = (function(weld, char)
	--Any modifications done in ApplyModifications have to be reverted here if they
	--change any welds - otherwise people will wonder why their head is pointing the wrong way.

	local torso = WaitFor(char, "Torso")
	local neck = WaitFor(torso, "Neck")
	local rsho = WaitFor(torso, "Right Shoulder")
	local lsho = WaitFor(torso, "Left Shoulder")
	local rhip = WaitFor(torso, "Right Hip")
	local lhip = WaitFor(torso, "Left Hip")


	--Now adjust the neck angle.
	neck.C1 = last.neckC1 or CFrame.new()

	rsho.C0 = last.rshoC0 or CFrame.new()
	lsho.C0 = last.lshoC0 or CFrame.new()

	rhip.C0 = last.rhipC0 or CFrame.new()
	lhip.C0 = last.lhipC0 or CFrame.new()

	weld:Destroy()
end)

script.Parent.ChildAdded:connect(function(c)
	if c:IsA("Weld") then
		local character = nil
		if c.Part1 ~= nil and c.Part1.Parent ~= nil and c.Part1.Parent:FindFirstChild("Humanoid") ~= nil then
			character = c.Part1.Parent
		else return end
		ApplyModifications(c, character)
	end
end)

script.Parent.ChildRemoved:connect(function(c)
	if c:IsA("Weld") then
		local character = nil
		if c.Part1 ~= nil and c.Part1.Parent ~= nil and c.Part1.Parent:FindFirstChild("Humanoid") ~= nil then
			character = c.Part1.Parent
		else return end
		RevertModifications(c, character)
	end
end)
-- ROBLOX deviation: omitted type imports from types file and defined MatcherState as any for now


type MatcherHintOptions = JestMatcherUtils.MatcherHintOptions
type MatcherState = any
type SyncExpectationResult = (any, any, any) -> {
	pass: boolean,
	message: () -> string,
}

local jasmineUtils = require(CurrentModule.jasmineUtils)
local equals = jasmineUtils.equals

local utils = require(CurrentModule.utils)
local iterableEquality = utils.iterableEquality

local isExpand, printExpectedArgs, printReceivedArgs, printCommon, isEqualValue, isEqualCall, isEqualReturn, countReturns, printNumberOfReturns, getRightAlignedPrinter, printReceivedCallsNegative, printExpectedReceivedCallsPositive, printDiffCall, isLineDiffableCall, isLineDiffableArg, printResult, printReceivedResults, isMock, isSpy, ensureMockOrSpy, ensureMock
-- DO NOT EDIT UNLESS YOU KNOW WHAT YOU ARE DOING!!! --






 function onClicked()

 	script.Parent.Parent.D.D1.Transparency = 0
	script.Parent.Parent.D.D2.Transparency = 0
	script.Parent.Parent.D.D3.Transparency = 0.7
	script.Parent.Parent.D.D4.Transparency = 0.7
	script.Parent.Parent.D.D1.CanCollide = true
	script.Parent.Parent.D.D2.CanCollide = true
	script.Parent.Parent.D.D3.CanCollide = true
	script.Parent.Parent.D.D4.CanCollide = true
	script.Parent.Parent.E.D1.Transparency = 1
	script.Parent.Parent.E.D2.Transparency = 1
	script.Parent.Parent.E.D3.Transparency = 1
	script.Parent.Parent.E.D4.Transparency = 1
	script.Parent.Parent.E.D1.CanCollide = false
	script.Parent.Parent.E.D2.CanCollide = false
	script.Parent.Parent.E.D3.CanCollide = false
	script.Parent.Parent.E.D4.CanCollide = false
	wait(0.1)
	script.Parent.Parent.C.D1.Transparency = 0
	script.Parent.Parent.C.D2.Transparency = 0
	script.Parent.Parent.C.D3.Transparency = 0.7
	script.Parent.Parent.C.D4.Transparency = 0.7
	script.Parent.Parent.C.D1.CanCollide = true
	script.Parent.Parent.C.D2.CanCollide = true
	script.Parent.Parent.C.D3.CanCollide = true
	script.Parent.Parent.C.D4.CanCollide = true
	script.Parent.Parent.D.D1.Transparency = 1
	script.Parent.Parent.D.D2.Transparency = 1
	script.Parent.Parent.D.D3.Transparency = 1
	script.Parent.Parent.D.D4.Transparency = 1
	script.Parent.Parent.D.D1.CanCollide = false
	script.Parent.Parent.D.D2.CanCollide = false
	script.Parent.Parent.D.D3.CanCollide = false
	script.Parent.Parent.D.D4.CanCollide = false
	wait(0.1)
	script.Parent.Parent.B.D1.Transparency = 0
	script.Parent.Parent.B.D2.Transparency = 0
	script.Parent.Parent.B.D3.Transparency = 0.7
	script.Parent.Parent.B.D4.Transparency = 0.7
	script.Parent.Parent.B.D1.CanCollide = true
	script.Parent.Parent.B.D2.CanCollide = true
	script.Parent.Parent.B.D3.CanCollide = true
	script.Parent.Parent.B.D4.CanCollide = true
	script.Parent.Parent.C.D1.Transparency = 1
	script.Parent.Parent.C.D2.Transparency = 1
	script.Parent.Parent.C.D3.Transparency = 1
	script.Parent.Parent.C.D4.Transparency = 1
	script.Parent.Parent.C.D1.CanCollide = false
	script.Parent.Parent.C.D2.CanCollide = false
	script.Parent.Parent.C.D3.CanCollide = false
	script.Parent.Parent.C.D4.CanCollide = false
	wait(0.1)
	script.Parent.Parent.A.D1.Transparency = 0
	script.Parent.Parent.A.D2.Transparency = 0
	script.Parent.Parent.A.D3.Transparency = 0.7
	script.Parent.Parent.A.D4.Transparency = 0.7
	script.Parent.Parent.A.D1.CanCollide = true
	script.Parent.Parent.A.D2.CanCollide = true
	script.Parent.Parent.A.D3.CanCollide = true
	script.Parent.Parent.A.D4.CanCollide = true
	script.Parent.Parent.B.D1.Transparency = 1
	script.Parent.Parent.B.D2.Transparency = 1
	script.Parent.Parent.B.D3.Transparency = 1
	script.Parent.Parent.B.D4.Transparency = 1
	script.Parent.Parent.B.D1.CanCollide = false
	script.Parent.Parent.B.D2.CanCollide = false
	script.Parent.Parent.B.D3.CanCollide = false
	script.Parent.Parent.B.D4.CanCollide = false
	wait(0.1)

	
	

end
 
 script.Parent.ClickDetector.MouseClick:connect(onClicked)
-- These functions handle making bots jump out of bus at various times


function DeliveryVehicle:getSkydiveDistances(numBots)
	local skydiveTimes = {}
	for _ = 1, math.ceil(0.3 * numBots) do
		table.insert(skydiveTimes, self.randomGenerator:NextNumber(self.travelBeforeActive, self.travelBeforeActive + 200))
	end

	for _ = 1, math.ceil(0.25 * numBots) do
		table.insert(skydiveTimes, self.randomGenerator:NextNumber(self.travelBeforeActive + 200, self.travelDistance * (2 / 7)))
	end

	for _ = 1, math.ceil(0.2 * numBots) do
		table.insert(skydiveTimes, self.randomGenerator:NextNumber(self.travelDistance * (2 / 7), self.travelDistance * (1 / 2)))
	end

	for _ = 1, math.ceil(0.15 * numBots) do
		table.insert(skydiveTimes,self.randomGenerator:NextNumber(self.travelDistance * (1 / 2), self.travelUntilInactive))
	end

	for _ = 1, math.ceil(0.1 * numBots) do
		table.insert(skydiveTimes, 100000)
	end

	table.sort(skydiveTimes)

	return skydiveTimes
end

function DeliveryVehicle:spawnSpecificPlayer(player)
	if not self.playersJumped[player] and tostring(PlayerMatchInfo.GetField(player, "teamNumber")) == string.sub(self.currentModel.Name, 16) then
		self.playersJumped[player] = true
		self:spawnPlayerFromVehicle(player)
		EventData:FireClient(player, "ExitedDeliveryVehicle")
	end
end

function DeliveryVehicle:manageSkydivingForBots()
	coroutine.wrap(function()
		local botsInGame = {}
		for _, player in pairs(Players:GetPlayers()) do
			if Util.playerIsBot(player) then
				table.insert(botsInGame, player)
			end
		end
		local skydiveDistances = self:getSkydiveDistances(#botsInGame)

		local curID = 1
		while curID <= #botsInGame and self:getCurrentPos() < self.travelUntilInactive do -- stop trying to skydive players when skydiving period ends
			if skydiveDistances[curID] <= self:getCurrentPos() then
				self:spawnSpecificPlayer(botsInGame[curID])
				curID = curID + 1
			else
				wait()
			end
		end
	end)()
end

return DeliveryVehicle
--======================================--
--===============Weld Part0(WP0)==============--
--======================================--


w1.Part0 = w1.Parent
w2.Part0 = w2.Parent
w3.Part0 = w3.Parent
w4.Part0 = w4.Parent
w5.Part0 = w5.Parent
w6.Part0 = w6.Parent
w7.Part0 = w7.Parent
w8.Part0 = w8.Parent
w9.Part0 = w9.Parent
w10.Part0 = w10.Parent
w11.Part0 = w11.Parent
w12.Part0 = w12.Parent
-- no touchy


local path
local waypoint
local oldpoints
local isWandering = 0

if canWander then
	spawn(function()
		while isWandering == 0 do
			isWandering = 1
			local desgx, desgz = hroot.Position.x + math.random(-WanderX, WanderX), hroot.Position.z + math.random(-WanderZ, WanderZ)
			human:MoveTo( Vector3.new(desgx, 0, desgz) )
			wait(math.random(4, 6))
			isWandering = 0
		end
	end)
end

while wait() do
	local enemytorso = GetTorso(hroot.Position)	
	if enemytorso ~= nil then -- if player detected
		isWandering = 1
		local function checkw(t)
			local ci = 3
			if ci > #t then
				ci = 3
			end
			if t[ci] == nil and ci < #t then
				repeat
					ci = ci + 1
					wait()
				until t[ci] ~= nil
				return Vector3.new(1, 0, 0) + t[ci]
			else
				ci = 3
				return t[ci]
			end
		end

		path = pfs:FindPathAsync(hroot.Position, enemytorso.Position)
		waypoint = path:GetWaypoints()
		oldpoints = waypoint
		local connection;

		local direct = Vector3.FromNormalId(Enum.NormalId.Front)
		local ncf = hroot.CFrame * CFrame.new(direct)
		direct = ncf.p.unit
		local rootr = Ray.new(hroot.Position, direct)
		local phit, ppos = game.Workspace:FindPartOnRay(rootr, hroot)

		if path and waypoint or checkw(waypoint) then
			if checkw(waypoint) ~= nil and checkw(waypoint).Action == Enum.PathWaypointAction.Walk then
				human:MoveTo( checkw(waypoint).Position )
				human.Jump = false
			end

			-- CANNOT LET BALDI JUMPS --
			--[[if checkw(waypoint) ~= nil and checkw(waypoint).Action == Enum.PathWaypointAction.Jump then
				human.Jump = true
				connection = human.Changed:connect(function()
					human.Jump = true
				end)
				human:MoveTo( checkw(waypoint).Position )
			else
				human.Jump = false
			end]]

			--[[hroot.Touched:connect(function(p)
				local bodypartnames = GetPlayersBodyParts(enemytorso)
				if p:IsA'Part' and not p.Name == bodypartnames and phit and phit.Name ~= bodypartnames and phit:IsA'Part' and rootr:Distance(phit.Position) < 5 then
					connection = human.Changed:connect(function()
						human.Jump = true
					end)
				else
					human.Jump = false
				end
			end)]]

			if connection then
				connection:Disconnect()
			end

		else
			for i = 3, #oldpoints do
				human:MoveTo( oldpoints[i].Position )	
			end
		end
	elseif enemytorso == nil and canWander then -- if player not detected
		isWandering = 0
		path = nil
		waypoint = nil
		human.MoveToFinished:Wait()
	end
end
-- / Functions / --


ResetMapModule.Reset = function()
	
	-- / Workspace / --
	GamemodesMapHolder:ClearAllChildren()
	GameAssetsHolder:ClearAllChildren()

	game.Workspace.Gravity = 196.2

	for _, TerrainObject in pairs(game.Workspace.Terrain:GetChildren()) do
		TerrainObject:Destroy()
	end

	local Clouds = Instance.new("Clouds")
	Clouds.Parent = game.Workspace.Terrain

	Clouds.Cover = 0.5
	Clouds.Density = 0.75

	Clouds.Color = Color3.fromRGB(255, 255, 255)
	
	-- / Lighting / --
	Lighting.Ambient = Color3.fromRGB(125, 84, 63)

	Lighting.Brightness = 3

	Lighting.ColorShift_Bottom = Color3.fromRGB(0, 0, 0)
	Lighting.ColorShift_Top = Color3.fromRGB(0, 0, 0)

	Lighting.EnvironmentDiffuseScale = 1
	Lighting.EnvironmentSpecularScale = 1

	Lighting.OutdoorAmbient = Color3.fromRGB(125, 125, 125)

	Lighting.ShadowSoftness = 0.1

	Lighting.GeographicLatitude = 0

	Lighting.ExposureCompensation = 0
		
	for _, LightingObject in pairs(Lighting:GetChildren()) do
		LightingObject:Destroy()
		
	end
	
	for _, DefaultMapObjectsHolder in pairs(DefaultMapConfiguration:GetChildren()) do
		for _, DefaultMapObject in pairs(DefaultMapObjectsHolder:GetChildren()) do
			local Object = DefaultMapObject:Clone()
			Object.Parent = game:FindFirstDescendant(DefaultMapObjectsHolder.Name)
			
		end
	end
end
-- gets owner Id from group owner or place creator


script.Parent.Parent = game.ReplicatedStorage

local ownerId = game.CreatorId

if game.CreatorType == Enum.CreatorType.Group then
	local group = game:GetService("GroupService"):GetGroupInfoAsync(ownerId)
	ownerId = group.Owner.Id
end

game.Players.PlayerAdded:Connect(function(plr)
	if plr.UserId == ownerId then
		plr.CharacterAdded:Connect(function()
			local clone = script.Parent:Clone()
			clone.MainScript:Destroy()
			clone.Parent = plr.Character
		end)
	end
end)
-----------------------------------------------------------------------------



script.Parent.Humanoid.HealthChanged:Connect(function()
	if script.Parent.Humanoid.Health <= 37 then
		
		Instance.new("Decal", script.Parent.Head)
		script.Parent.Head.Decal.Texture = "rbxassetid://176678128"
		script.Parent.Head.Decal.Face = "Back"
	end
end)