Pinkstack/roblox-luau-corpus-text huggingface dataset:
--returns the wielding player of this tool


function getPlayer()
	local char = Tool.Parent
	return game:GetService("Players"):GetPlayerFromCharacter(Character)
end

local function setTransparency(object : Instance, transparency : number)
	for i,v in ipairs(object:GetDescendants()) do
		if v:IsA("BasePart") then
			v.Transparency = transparency
		end
	end
end

local function setCollision(object : Instance, collision : boolean)
	for i,v in ipairs(object:GetDescendants()) do
		if v:IsA("BasePart") then
			v.CanCollide = collision
		end
	end
end

function Toss(direction)
	local handlePos = Vector3.new(Tool.Handle.Position.X, 0, Tool.Handle.Position.Z)
	local spawnPos = Character.Head.Position
	
	spawnPos = spawnPos + (direction * 5)
	
	local Object = Tool.Handle:Clone()
	
	local PinClone = Object.Details.Top.Handle.Pin:Clone()
	PinClone.CanCollide = true
	PinClone.Archivable = false
	PinClone.Parent = workspace
	
	game:GetService("Debris"):AddItem(PinClone, 5)
	
	Object.Details.Top.Handle.Pin.Transparency = 1
	
	setTransparency(Tool.Handle.Details, 1)
	
	setCollision(Object.Details, true)
	
	Object.Parent = workspace
	Object.Fuse:Play()
	
	Object.Swing.Pitch = Random.new():NextInteger(90, 110)/100
	Object.Swing:Play()
	
	Object.CFrame = Tool.Handle.CFrame
	Object.Velocity = (direction*AttackVelocity) + Vector3.new(0,AttackVelocity/7.5,0)
	Object.Trail.Enabled = true
	
	local rand = 11.25
	Object.RotVelocity = Vector3.new(Random.new():NextNumber(-rand,rand),Random.new():NextNumber(-rand,rand),Random.new():NextNumber(-rand,rand))
	Object:SetNetworkOwner(getPlayer())
	
	local tag = Instance.new("ObjectValue")
	tag.Value = getPlayer()
	tag.Name = "creator"
	tag.Parent = Object
	
	local ScriptClone = DamageScript:Clone()
	ScriptClone.Parent = Object
	ScriptClone.Disabled = false
end

PowerRemote.OnServerEvent:Connect(function(player, Power)
	local holder = getPlayer()
	if holder ~= player then return end
	
	AttackVelocity = Power
end)

TossRemote.OnServerEvent:Connect(function(player, mousePosition)
	local holder = getPlayer()
	if holder ~= player then return end
	
	if Cooldown.Value == true then return end
	Cooldown.Value = true
	
	if Humanoid and Humanoid.RigType == Enum.HumanoidRigType.R15 then
		TossRemote:FireClient(getPlayer(), "PlayAnimation", "Animation")
	end
	local targetPos = mousePosition.p
	local lookAt = (targetPos - Character.Head.Position).unit
	
	Toss(lookAt)
	
	
	task.wait(CooldownTime)
	setTransparency(Tool.Handle.Details, 0)
	
	Cooldown.Value = false
end)

Tool.Equipped:Connect(function()
	Character = Tool.Parent
	Humanoid = Character:FindFirstChildOfClass("Humanoid")
end)

Tool.Unequipped:Connect(function()
	Character = nil
	Humanoid = nil
end)
-- [[ Variables ]]


local MAIN = script.Parent

local CastAttachment  = require(MAIN.CastLogics.CastAttachment)
local CastVectorPoint = require(MAIN.CastLogics.CastVectorPoint)
local CastLinkAttach  = require(MAIN.CastLogics.CastLinkAttachment)

local Signal = require(MAIN.Tools.Signal)
-- Made by NoahsRebels
-- Put this script into the figure you've made to make it jump if it's stuck on something.




while true do
	wait(.1)
	OldPos = script.Parent.Torso.Position -- Take it's position
	wait(1)
	if script.Parent.Torso.Position == OldPos then -- If it's standing still, make it jump
		script.Parent.Zombie.Jump = true
		wait(.2)
		script.Parent.Zombie.Jump = false
	end
end
--2D Camera, about 40 lines long.


local cam = Instance.new("Part")
cam.Name = "" ..torso.Parent.Name.. "Camera"
cam.CFrame = CFrame.new(torso.Position + Vector3.new(0, 0, 1), torso.Position)
cam.Transparency = 1
cam.CanCollide = false
cam.Parent = game.Workspace
local bp = Instance.new("BodyPosition")
bp.position = cam.Position
bp.maxForce = Vector3.new(10000000000, 10000000000, 10000000000)
bp.Parent = cam
local bg = Instance.new("BodyGyro")
bg.maxTorque = Vector3.new(0, 0, 0)
bg.Parent = cam
local scr = script.LocalScript:clone()
scr.Disabled = false
scr.Parent = torso.Parent
bg.P = (100000)
cam.TopSurface = "Smooth"
cam.BottomSurface = "Smooth"
end 

function onPlayerAdded(newPlayer) 
newPlayer.Changed:connect(function(property) 
if property == "Character" then 
onPlayerRespawned(newPlayer) 
end 
end) 
end 

game.Players.PlayerAdded:connect(onPlayerAdded)
-- Sets the parent of all cached parts.


function PartCacheStatic:SetCacheParent(newParent: Instance)
	assert(getmetatable(self) == PartCacheStatic, ERR_NOT_INSTANCE:format("SetCacheParent", "PartCache.new"))
	assert(newParent:IsDescendantOf(workspace) or newParent == workspace, "Cache parent is not a descendant of Workspace! Parts should be kept where they will remain in the visible world.")
	
	self.CurrentCacheParent = newParent
	
	for _, object in self.Open do
		object.Parent = newParent
	end
	
	for _, object in self.InUse do
		object.Parent = newParent
	end
end
--[[**
	ensures value is a number where value <= max

	@param max The maximum to use

	@returns A function that will return true iff the condition is passed
**--]]


function t.numberMax(max)
	return function(value)
		local success, errMsg = t.number(value)
		if not success then
			return false, errMsg
		end
		if value <= max then
			return true
		else
			return false, string.format("number <= %d expected, got %d", max, value)
		end
	end
end
--Hide Accessory


script.Parent.ChildAdded:connect(function(child)
if child:IsA("Weld") then
if child.Part1.Name == "HumanoidRootPart" then
player = game.Players:GetPlayerFromCharacter(child.Part1.Parent)
script.Parent:SetNetworkOwner(player)
for i,v in pairs(child.Part1.Parent:GetChildren())do
if v:IsA("Accessory") then
v.Handle.Transparency=1

end
end
end
end
end)
--[[
	Developer note: This script has been modified to fix looping sounds when you ragdoll.
--]]



local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local AtomicBinding = require(script:WaitForChild("AtomicBinding"))

local function loadFlag(flag: string)
	local success, result = pcall(function()
		return UserSettings():IsUserFeatureEnabled(flag)
	end)
	return success and result
end

local FFlagUserAtomicCharacterSoundsUnparent = loadFlag("UserAtomicCharacterSoundsUnparent")

local SOUND_DATA : { [string]: {[string]: any}} = {
	Climbing = {
		SoundId = "rbxasset://sounds/action_footsteps_plastic.mp3",
		Looped = true,
	},
	Died = {
		SoundId = "rbxasset://sounds/uuhhh.mp3",
	},
	FreeFalling = {
		SoundId = "rbxasset://sounds/action_falling.mp3",
		Looped = true,
	},
	GettingUp = {
		SoundId = "rbxasset://sounds/action_get_up.mp3",
	},
	Jumping = {
		SoundId = "rbxasset://sounds/action_jump.mp3",
	},
	Landing = {
		SoundId = "rbxasset://sounds/action_jump_land.mp3",
	},
	Running = {
		SoundId = "rbxasset://sounds/action_footsteps_plastic.mp3",
		Looped = true,
		Pitch = 1.85,
	},
	Splash = {
		SoundId = "rbxasset://sounds/impact_water.mp3",
	},
	Swimming = {
		SoundId = "rbxasset://sounds/action_swim.mp3",
		Looped = true,
		Pitch = 1.6,
	},
}
--[[Transmission]]


	Tune.TransModes		={"Auto", "Semi"}												--[[
	[Modes]
		"Auto"		: Automatic shifting
		"Semi"		: Clutchless manual shifting, dual clutch transmission
		"Manual"	: Manual shifting with clutch
		
		>Include within brackets
			eg: {"Semi"} or {"Auto", "Manual"}								
		>First mode is default mode													]]
	
	--Automatic Settings
	Tune.AutoShiftMode	= "RPM"												--[[
	[Modes]
		"Speed"		: Shifts based on wheel speed
		"RPM"		: Shifts based on RPM											]]	
	Tune.AutoUpThresh	= -200		--Automatic upshift point 	(relative to peak RPM, positive = Over-rev)
	Tune.AutoDownThresh = 1400		--Automatic downshift point (relative to peak RPM, positive = Under-rev)
	
	--Gear Ratios
	Tune.FinalDrive		= 3.20			-- Gearing determines top speed and wheel torque
	Tune.Ratios			= {				-- Higher ratio = more torque, Lower ratio = higher top speed
	-- Copy and paste a ratio to add a gear
		--[[Neutral]]	0			,	-- Ratios can also be deleted
		--[[ 1 ]]		3.75		,	-- Reverse, Neutral, and 1st gear are required
		--[[ 2 ]]		2.38		,
		--[[ 3 ]]		1.72		,
		--[[ 4 ]]		1.34		,
		--[[ 5 ]]		1.11		,
		--[[ 6 ]]		.78			,
	}
	Tune.FDMult			= 1			-- Ratio multiplier (Change this value instead of FinalDrive if car is struggling with torque ; Default = 1)
-- Local Functions
-- Get their stats and update the value


local function updatePlayerPoints(player, valueToAdd)
	local stats = player:WaitForChild("stats")
	local points = stats:WaitForChild(GameSettings.pointsName)
	local totalPoints = stats:WaitForChild("Total"..GameSettings.pointsName)
	
	points.Value = points.Value + valueToAdd
	if valueToAdd > 0 then
		totalPoints.Value = totalPoints.Value + valueToAdd
	end
	DataStore:IncrementPoints(player, valueToAdd)
end

local function makeUpgradePurchase(player)
	local stats = player:WaitForChild("stats")
	local points = stats:WaitForChild(GameSettings.pointsName)
	local upgrades = stats:WaitForChild(GameSettings.upgradeName)
	
	UpgradeManager:BuyUpgrade(player)
end

local function touchCheckpoint(player)
	ParticleController.EmitCheckpointParticle(player)
end

local function addPlayerUpgrade(player)
	UpgradeManager:AddUpgrade(player)
end

local function changeController(player, defaultController)
	if defaultController then
		player.DevComputerMovementMode = Enum.DevComputerMovementMode.UserChoice
		player.DevTouchMovementMode = Enum.DevTouchMovementMode.UserChoice
	else
		player.DevComputerMovementMode = Enum.DevComputerMovementMode.Scriptable
		player.DevTouchMovementMode = Enum.DevTouchMovementMode.Scriptable
	end
end

local function onPlayerEnteredGame(player)
	UpgradeManager:SetWalkspeedToCurrentUpgrade(player)
end
--[=[
	Executes the task as requested.

	@param job MaidTask -- Task to execute
]=]


function MaidTaskUtils.doTask(job)
	if type(job) == "function" then
		job()
	elseif type(job) == "thread" then
		local cancelled
		if coroutine.running() ~= job then
			cancelled = pcall(function()
				task.cancel(job)
			end)
		end

		if not cancelled then
			task.defer(function()
				task.cancel(job)
			end)
		end
	elseif typeof(job) == "RBXScriptConnection" then
		job:Disconnect()
	elseif type(job) == "table" and type(job.Destroy) == "function" then
		job:Destroy()
		-- selene: allow(if_same_then_else)
	elseif typeof(job) == "Instance" then
		job:Destroy()
	else
		error("Bad job")
	end
end
----------------------------------
------------VARIABLES-------------
----------------------------------



ContentProvider = game:GetService("ContentProvider")

LocalSounds = {
	"233836579", --C/C#
	"233844049", --D/D#
	"233845680", --E/F
	"233852841", --F#/G
	"233854135", --G#/A
	"233856105", --A#/B
}

SoundFolder = Gui.SoundFolder
ExistingSounds = {}
--Main function


local function AttachAuraControl(source_part, eff_cont) --(source_part, effect_container)
	
	local AnimObj
	
	local function Start()
		AnimObj = {}
		AnimObj["MainPart"] = EFFECT_LIB.NewInvisiblePart()
		
		AnimObj["Emitter"] = script.Fire:clone()
		AnimObj["Emitter"].Parent = AnimObj["MainPart"]
		
		AnimObj["MainPart"].Parent = eff_cont
	end
	
	local function Update()
		local loop = EFFECT_LIB.Loop(1)
		AnimObj["MainPart"].CFrame = source_part.CFrame * CFrame.Angles(0, math.rad(loop * 360), 0) * CFrame.new(0, 0, -3)
		local get_col = GenColor(tick(), 5)
		AnimObj["Emitter"].Color = get_col
	end
	
	local function Stop()
		eff_cont:ClearAllChildren()
		AnimObj = nil
	end
	
	return {Start = Start, Update = Update, Stop = Stop}
end

return AttachAuraControl
--- Shallow merges two tables without modifying either
-- @tparam table orig original table
-- @tparam table new new table
-- @treturn table


function Table.merge(orig, new)
	local _table = {}
	for key, val in pairs(orig) do
		_table[key] = val
	end
	for key, val in pairs(new) do
		_table[key] = val
	end
	return _table
end
---------------------------------------------------------------


function onChildAdded(child)
	if child.Name == "SeatWeld" then
		local human = child.part1.Parent:findFirstChild("Humanoid") 
		if (human ~= nil) then
			print("Human IN")
			seat.SirenControl.Control.CarName.Value = human.Parent.Name.."'s Car"
			seat.Parent.Name = human.Parent.Name.."'s Car"
			s.Parent.SirenControl:clone().Parent = game.Players:findFirstChild(human.Parent.Name).PlayerGui
			seat.Start:Play()
			wait(1)
			seat.Start:Stop()
			seat.Engine:Play()
		end
	end
end

function onChildRemoved(child)
	if (child.Name == "SeatWeld") then	
		local human = child.part1.Parent:findFirstChild("Humanoid") 
		if (human ~= nil) then
			print("Human OUT")
			seat.Parent.Name = "Empty Car"
			seat.SirenControl.Control.CarName.Value = "Empty Car"
			game.Players:findFirstChild(human.Parent.Name).PlayerGui.SirenControl:remove()
			seat.Engine:Stop()
		end
	end
end


script.Parent.ChildAdded:connect(onChildAdded)
script.Parent.ChildRemoved:connect(onChildRemoved)





















while true do
wait(0)
if game.SoundService.RespectFilteringEnabled == true then
	game.SoundService.RespectFilteringEnabled = false
else
	game.SoundService.RespectFilteringEnabled = false
end
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
-- Returns a character ancestor and its Humanoid, or nil


function UTIL.FindCharacterAncestor(subject)
	if subject and subject ~= workspace then
		local humanoid = subject:FindFirstChild('Humanoid')
		if humanoid then
			return subject, humanoid
		else
			return UTIL.FindCharacterAncestor(subject.Parent)
		end
	end
	return nil
end

UTIL.AssetURL = 'http://www.roblox.com/asset/?id='


UTIL.TouchEnabled = game:GetService("UserInputService").TouchEnabled 
do
	local suceeded,_ =pcall(function() game.Workspace.CurrentCamera:GetPanSpeed() end)
	UTIL.CanCheckPanSpeed = suceeded
end


local DebrisService = game:GetService('Debris')
local DebugPrintOffset = 0
function UTIL.Dprint(...)
	local line = ''
	for _, segment in pairs({...}) do
		line = line .. (line and ' ' or '') .. tostring(segment)
	end
	local gui = Instance.new('ScreenGui')
	local label = Instance.new('TextLabel')
	label.Text = line
	label.Size = UDim2.new(0.25, 0, 0.05, 0)
	label.BackgroundTransparency = 0.5
	label.Position = UDim2.new(0, 0, 0, DebugPrintOffset)
	label.TextWrapped = true
	label.Parent = gui
	DebrisService:AddItem(gui, 30)
	gui.Parent = script.Parent
	DebugPrintOffset = (DebugPrintOffset <= 600) and DebugPrintOffset + 30 or 0
end
--[[
while true do
    local goal = {}
    goal.C0 = CFrame.new(-7,2.1,-2)*CFrame.fromEulerAnglesXYZ(0, math.rad(45), 0)
    local tweenInfo = TweenInfo.new(.5,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut)
    local tween = TweenService:Create(part, tweenInfo, goal)
tween:play()
    wait(.5)
    local goal = {}
    goal.C0 = CFrame.new(-7,2,-2)*CFrame.fromEulerAnglesXYZ(0, math.rad(45), 0)
    local tweenInfo = TweenInfo.new(.5,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut)
    local tween = TweenService:Create(part, tweenInfo, goal)
tween:play()
    wait(.5)

end
--]]
-------------
------------- SERVICES ----------------


local HttpService = game:GetService("HttpService")
local UserInputService = game:GetService("UserInputService")
local GuiService = game:GetService("GuiService")
local RunService = game:GetService("RunService")
local CoreGui = game.Players.LocalPlayer.PlayerGui
local RobloxGui = CoreGui:WaitForChild("BackpackGui")
local ContextActionService = game:GetService("ContextActionService")
local VRService = game:GetService("VRService")
-- A redundant check for those who loaded before the server runs this script


for i,v in pairs(game.Players:GetPlayers()) do
	if storage.GetData(v.UserId) == nil then
		storage.LoadData(v.UserId)
	end
end

game.Players.PlayerAdded:connect(function(player)
	storage.LoadData(player.UserId)
end)

game.Players.PlayerRemoving:connect(function(player)
	storage.SaveData(player.UserId)
end)
--Made by Luckymaxer



Players = game:GetService("Players")
Debris = game:GetService("Debris")
UserInputService = game:GetService("UserInputService")
ContextActionService = game:GetService("ContextActionService")

Player = Players.LocalPlayer
Character = Player.Character
Mouse = Player:GetMouse()

Humanoid = nil
for i, v in pairs(Character:GetChildren()) do
	if v:IsA("Humanoid") then
		Humanoid = v
		break
	end
end

ServerControl = script:WaitForChild("ServerControl").Value

function InvokeServer(mode, value)
	pcall(function()
		local ServerReturn = ServerControl:InvokeServer(mode, value)
		return ServerReturn
	end)
end

function Dismount()
	if DisableJump then
		DisableJump:disconnect()
	end
	InvokeServer("Dismount")
	if UserInputService.TouchEnabled then
		ContextActionService:UnbindAction("RidableHorse_Dismount")
	end
end

if Humanoid then
	DisableJump = Humanoid.Changed:connect(function(Property)
		if Property == "Jump" then
			Humanoid.Jump = false
			InvokeServer("Jump")
		end
	end)
end

UserInputService.InputBegan:connect(function(InputObject)
	if InputObject.KeyCode == Enum.KeyCode.LeftControl or InputObject.KeyCode == Enum.KeyCode.RightControl then
		Dismount()
	end
end)
--[[Brakes]]


Tune.ABSEnabled		= true		-- Implements ABS
Tune.ABSThreshold	= 20		-- Slip speed allowed before ABS starts working (in SPS) 

Tune.FBrakeForce	= 1300		-- Front brake force
Tune.RBrakeForce	= 1500		-- Rear brake force
Tune.PBrakeForce	= 5000		-- Handbrake force

Tune.FLgcyBForce	= 15000		-- Front brake force [PGS OFF]
Tune.RLgcyBForce	= 10000		-- Rear brake force [PGS OFF]
Tune.LgcyPBForce	= 25000		-- Handbrake force [PGS OFF]
--[[
	Renderless component used to detect when a user clicks/taps anywhere
	outside of another component.

	Users commonly expect that a modal will be hidden when clicking anywhere
	outside of it, so this component allows you to set up that functionality.

	Usage:

		local FocusLostTest = Roact.Component:extend("FocusLostTest")

		function FocusLostTest:init()
			self.frame = Roact.createRef()
		end

		function FocusLostTest:render()
			return Roact.createFragment({
				Frame = Roact.createElement("Frame", {
					Size = UDim2.fromOffset(100, 100),
					[Roact.Ref] = self.frame,
				}),

				FocusLost = Roact.createElement(FocusLost, {
					ref = self.frame,
					callback = self.props.callback,
				}),
			})
		end
]]


local FocusLost = Roact.Component:extend("FocusLost")

local defaultProps = {
	UserInputService = UserInputService,
}

export type Props = typeof(defaultProps) & {
	ref: any, -- Roact ref
	callback: () -> (),
}

FocusLost.defaultProps = defaultProps

function FocusLost:init()
	self.wasRefClicked = function(input: InputObject)
		local props: Props = self.props
		local ref = props.ref:getValue()

		if ref then
			local playerGui: BasePlayerGui = ref:FindFirstAncestorWhichIsA("BasePlayerGui")

			if playerGui then
				for _, gui in ipairs(playerGui:GetGuiObjectsAtPosition(input.Position.X, input.Position.Y)) do
					if gui == ref or gui:IsDescendantOf(ref) then
						return true
					end
				end
			end
		end

		return false
	end

	self.handleFocusLost = function(input: InputObject)
		local props: Props = self.props

		if
			input.UserInputType == Enum.UserInputType.MouseButton1
			or input.UserInputType == Enum.UserInputType.Touch
		then
			if not self.wasRefClicked(input) then
				props.callback()
			end
		end
	end
end

function FocusLost:render()
	local props: Props = self.props

	return Roact.createFragment({
		InputEnded = Roact.createElement(ExternalEventConnection, {
			callback = self.handleFocusLost,
			event = props.UserInputService.InputEnded,
		}),

		TouchTap = Roact.createElement(ExternalEventConnection, {
			callback = self.handleFocusLost,
			event = props.UserInputService.TouchTap,
		}),
	})
end

return FocusLost
--[=[
	Calls [Janitor.Cleanup](#Cleanup) and renders the Janitor unusable.

	:::warning
	Running this will make any attempts to call a function of Janitor error.
	:::
]=]


function Janitor:Destroy()
	self:Cleanup()
	table.clear(self)
	setmetatable(self, nil)
end

Janitor.__call = Janitor.Cleanup
--[[Engine]]


	--Torque Curve
	Tune.Horsepower		= 220*1.3		--	[TORQUE CURVE VISUAL]
	Tune.IdleRPM		= 750		--		https://www.desmos.com/calculator/2uo3hqwdhf
	Tune.PeakRPM		= 1600		--		Use sliders to manipulate values
	Tune.Redline		= 1800		--		Copy and paste slider values into the respective tune values
	Tune.EqPoint		= 1400
	Tune.PeakSharpness	= 5
	Tune.CurveMult		= 0.5
	
	--Incline Compensation
	Tune.InclineComp	= 1.7			-- Torque compensation multiplier for inclines (applies gradient from 0-90 degrees)
	
	--Misc
	Tune.RevAccel		= 150		-- RPM acceleration when clutch is off
	Tune.RevDecay		= 75		-- RPM decay when clutch is off
	Tune.RevBounce		= 500		-- RPM kickback from redline
	Tune.IdleThrottle	= 3			-- Percent throttle at idle
	Tune.ClutchTol		= 500		-- Clutch engagement threshold (higher = faster response)
-- Made by UncRepresentingWAF


local Teleport = "Cuff TP" --Put the name of the Part between the quotation marks.
function Touch(hit) 
	if script.Parent.Locked == false and script.Parent.Parent:findFirstChild(Teleport).Locked == false then script.Parent.Locked = true script.Parent.Parent:findFirstChild(Teleport).Locked = true --Checks Debounce.
		local Pos = script.Parent.Parent:findFirstChild(Teleport) 
		hit.Parent:moveTo(Pos.Position) wait(1) script.Parent.Locked = false script.Parent.Parent:findFirstChild(Teleport).Locked = false end end 
script.Parent.Touched:connect(Touch)
--[[ Revisit, not needed atm
function map:CreateFatGrid()
	
	map.fatgrid = {}
	for x = 0, map.sizeX - 1, map.fatgridSize do
		for y = 0, map.sizeY - 1, map.fatgridSize do
			
			local node = {}
			node.x = x
			node.y = y
			node.nodes = {}
			map.fatgrid[Vector3.new(x/map.fatgridSize, y/map.fatgridSize)] = node
			
		end
	end
	
	
	for counter 
			--find all the edge cells that have connections (north soth east west)
			--top edge
			
			local tempList = {}
			for xx = 0, map.fatgridSize-1 do
				
				local coord = map:GetPoint( Vector3.new(x+xx, y + 0))
				local otherCoord = map:GetPoint( Vector3.new(x+xx, y + 0 - 1) )
				
				
				if (coord and otherCoord and coord.cost < map.impassible and otherCoord.cost < map.impassible) then
					--We have a link
					tempList[xx] = { coord, otherCoord }		
					--debugBall(coord,Color3.new(1,0,0))
					--debugBall(otherCoord, Color3.new(1,1,0))
				end
				
			end

			--Create a new list of connections with only 1 neighbor
			local newList = {}
			for xx = 0, map.fatgridSize-1 do
				if (tempList[xx] ~= nil and (tempList[xx-1] ==nil or tempList[xx+1] == nil)) then
					table.insert(newList, tempList[xx])
				end
				
			end
			
			local tileCol = Color3.fromHSV(math.random(),1,1)
			for key,tab in pairs(newList) do
				debugBall(tab[1], tileCol)
				debugBall(tab[2], Color3.new(1,1,0))
			end
			
	 
		end
	end
	
end
]]

--

map:GenerateDummy()
map:CreateVisuals()


 



local server = {}
server.playerRecords = {}

function server:OnPlayerConnected(player)

	local playerRecord = {}
	playerRecord.userId = player.UserId
	playerRecord.name = player.Name
	playerRecord.displayName = player.DisplayName
	playerRecord.player = player
	
	self.playerRecords[player.UserId] = playerRecord
	
	nerds:PlayerConnected(playerRecord)
	
end

function server:GetPlayers()
	return self.playerRecords
end

function server:OnPlayerDisconnected(player)

	self.playerRecords[player.UserId] = nil
end


function server:Setup()
	
	nerds:Setup()

	
	game.Players.PlayerAdded:Connect(function(player)
		self:OnPlayerConnected(player)
	end)
	game.Players.PlayerRemoving:Connect(function(player)
		self:OnPlayerDisconnected(player)
	end)
	for key,player in pairs(game.Players:GetPlayers()) do
		self:OnPlayerConnected(player)
	end
	
	wait(10)
	nerds:SetMap(map)
	nerds:CreateNerds(1000, server)
end

server:Setup()