Plot System Bug

I’ve been trying to get this plot system to work for the past couple hours, and I just cant seem to get it to work.

Error:

Plot Setup(Workspace):
image

Code:

local plots = workspace:WaitForChild("Plots")
local re = game:GetService("ReplicatedStorage"):FindFirstChild("PlotSystemRE")

if not re then
	print("PlotSystemRE not found.")
end

-- Initialize the plots
for _, plot in ipairs(plots:GetChildren()) do
	local ownerValue = Instance.new("StringValue", plot)
	ownerValue.Name = "Owner"
	local spawnLocation = plot:FindFirstChild("SpawnLocation")
	if spawnLocation then
		plot:SetPrimaryPartCFrame(spawnLocation.CFrame)
		print("Initialized plot " .. plot.Name .. " at " .. tostring(spawnLocation.CFrame.Position))
	else
		print("SpawnLocation not found for plot " .. plot.Name)
	end
end

-- Assign a plot to a player
local function assignPlot(player)
	local availablePlots = {}
	for i, plot in ipairs(plots:GetChildren()) do
		if plot.Owner.Value == "" then
			table.insert(availablePlots, plot)
		end
	end

	if #availablePlots > 0 then
		local plot = availablePlots[math.random(#availablePlots)]
		plot.Owner.Value = tostring(player.UserId)
		local spawnLocation = plot:FindFirstChild("SpawnLocation")
		if spawnLocation then
			local center = spawnLocation.Value
			player.Character.HumanoidRootPart.CFrame = CFrame.new(center.X, center.Y + 5, center.Z)
			print("Assigned plot", plot.Name, "to player", player.Name, "at", center)
			if re then
				re:FireClient(player, plot.Name)
			else
				print("PlotSystemRE not found on client")
			end
		else
			print("SpawnLocation not found for plot", plot.Name)
		end
	else
		print("No available plots to assign to player", player.Name)
	end
end

-- Remove a player from their assigned plot
local function leavePlot(player)
	for _, plot in ipairs(plots:GetChildren()) do
		if plot.Owner.Value == tostring(player.UserId) then
			plot.Owner.Value = ""
			print("Player " .. player.Name .. " left plot " .. plot.Name)
			break
		end
	end
end

local players = game:GetService("Players")

local function onPlayerAdded(player)
	print("Player " .. player.Name .. " joined the game.")
	local character = player.Character or player.CharacterAdded:Wait()
	if character then
		local humanoid = character:WaitForChild("Humanoid")
		local playerGui = character:WaitForChild("PlayerGui")
	end
end
players.PlayerAdded:Connect(onPlayerAdded)

-- Connect the functions to player events
game.Players.PlayerAdded:Connect(function(player)
	print("Player " .. player.Name .. " joined the game.")
	print("Plots found: " .. #plots:GetChildren())
	assignPlot(player)
end)

game.Players.PlayerRemoving:Connect(function(player)
	leavePlot(player)
end)

I think it needs to be a model and not a folder.

The problem with this line is that plot is a Folder. Folder’s aren’t parts in the workspace and therefore you cannot set them to be in certain locations as they are just meant to organize objects in your project. If you have a Model or a Part that you wish to set to that location that would work but not a folder. Just a guess but maybe you really want to do this instead:

plot.Plate1:SetPrimaryPartCFrame(spawnLocation.CFrame)

Ended up getting the same error:

Updated Code:

local plots = workspace:WaitForChild("Plots")
local re = game:GetService("ReplicatedStorage"):FindFirstChild("PlotSystemRE")

if not re then
	print("PlotSystemRE not found.")
end

-- Initialize the plots
for _, plot in ipairs(plots:GetChildren()) do
	local ownerValue = Instance.new("StringValue", plot.Settings)
	ownerValue.Name = "Owner"
	local spawnLocation = plot:FindFirstChild("SpawnLocation")
	if spawnLocation then
		plot.Plate:SetPrimaryPartCFrame(spawnLocation.CFrame)
		print("Initialized plot " .. plot.Name .. " at " .. tostring(spawnLocation.CFrame.Position))
	else
		print("SpawnLocation not found for plot " .. plot.Name)
	end
end

local function assignPlot(player)
	local availablePlots = {}
	for i, plot in ipairs(plots:GetChildren()) do
		if plot.Settings.Owner.Value == "" then
			table.insert(availablePlots, plot)
		end
	end

	if #availablePlots > 0 then
		local plot = availablePlots[math.random(#availablePlots)]
		plot.Settings.Owner.Value = tostring(player.UserId)

		local character = player.Character or player.CharacterAdded:Wait()
		local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
		local spawnLocation = plot:WaitForChild("SpawnLocation")

		humanoidRootPart.CFrame = spawnLocation.CFrame + Vector3.new(0, 5, 0)

		print("Assigned plot", plot.Name, "to player", player.Name, "at", spawnLocation.Position)
		if re then
			re:FireClient(player, plot.Name)
		else
			print("PlotSystemRE not found on client")
		end
	else
		print("No available plots to assign to player", player.Name)
	end
end
-- Remove a player from their assigned plot
local function leavePlot(player)
	for _, plot in ipairs(plots:GetChildren()) do
		if plot.Settings.Owner.Value == tostring(player.UserId) then
			plot.Settings.Owner.Value = ""
			print("Player " .. player.Name .. " left plot " .. plot.Name)
			break
		end
	end
end

local players = game:GetService("Players")

local function onPlayerAdded(player)
	print("Player " .. player.Name .. " joined the game.")
	player.CharacterAdded:Connect(function(character)
		local humanoid = character:WaitForChild("Humanoid")
		local playerGui = character:WaitForChild("PlayerGui")
	end)
end
players.PlayerAdded:Connect(onPlayerAdded)

-- Connect the functions to player events
game.Players.PlayerAdded:Connect(function(player)
	print("Player " .. player.Name .. " joined the game.")
	print("Plots found: " .. #plots:GetChildren())
	assignPlot(player)
end)

game.Players.PlayerRemoving:Connect(function(player)
	leavePlot(player)
end)

image

Your error is talking about Plot3, is it different from Plot2 you are showing?

Al of the plots are the exact same. I was just showing the setup of it. Thats just the error the code gives me.

Try replacing SetPrimaryPartCFrame with PivotTo.

1 Like

Yeah sorry it is getting late for me…Plate needs to be a model to use that function but if you just want to move the part to the spawn location you can do this since Plate is a part and not a model:

plot.Plate.Position = spawnLocation.Position  --You could also do CFrames here too if you want.
1 Like

Heres what that did,

It also moved the basplates underground I believe

Try calling BreakJoints on the part instead. Maybe if the part is a part, change the CFrame directly.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.