CCCPaste

PlotHolder System

local replicatedstorage = game.ReplicatedStorage

local plotholder = Instance.new("Folder")
plotholder.Parent = replicatedstorage
plotholder.Name = "PlotHolders"

local Players = game.Players

Players.PlayerAdded:Connect(function(player)
	local plotnumber = Instance.new("IntValue")
	plotnumber.Name = "plotnumber"
	plotnumber.Parent = player

	for i = 1, 6 do
		if plotholder:FindFirstChild(i) then 
			continue
		end
		local claimplot = Instance.new("ObjectValue")
		claimplot.Parent = plotholder
		claimplot.Name = i
		claimplot.Value = player
		
		plotnumber.Value = i
		break
	end
	if plotnumber.Value == 0 then
		player:Kick("Too many players are in the game!")
	end
	local plotFolder = workspace.Map.Plots:FindFirstChild(plotnumber.Value)
	player.CharacterAdded:Connect(function(character)
		local tppart = plotFolder.TpPart
		
		character:PivotTo(tppart.CFrame)
	end)
	local sign = plotFolder.Sign
	local plottext = sign.DisplayPart.SurfaceGui.TextLabel
	plottext.Text = player.Name .. "'s Plot"
	
	local thumbnailtype = Enum.ThumbnailType.HeadShot
	local thumbnailSize = Enum.ThumbnailSize.Size420x420
	
	local playerIcon, isready = Players:GetUserThumbnailAsync(player.UserId, thumbnailtype, thumbnailSize)
	
	sign.DisplayPart.SurfaceGui.ImageLabel.Image = playerIcon
	
	sign.DisplayPart.SurfaceGui.Enabled = true
end)

Players.PlayerRemoving:Connect(function(player)
	local PlotNumber = player.PlotNumber.Value
	local plotclaimed = plotholder:FindFirstChild(PlotNumber)
	plotclaimed:Destroy()
	local playerplot = workspace.Map.Plots:FindFirstChild(PlotNumber)
	playerplot.Sign.DisplayPart.SurfaceGui.Enabled = false
end)