So, I’ve been working on a placement system, and I wanted to add an important feature. Saving the building the player has built.
I’ve successfully managed to create what I wanted before, but after adding the plot system, things have changed.
My plot system can only be defined by an object value on the replicated storage, which handles the plot that the player had got.
The problem is, when I try to make a variable about it in a server script, it doesn’t work. When making a variable about it in a client script. It works.
My plot object value:
My plot handler (Server Script Service):
game.Players.PlayerAdded:Connect(function(plr)
for _, plt in pairs(workspace.Plots:GetChildren()) do
if plt.Owner.Value ~= nil then
else
plt.Owner.Value = plr -- Object Value
plt.OwnerName.Value = plr.Name
game.ReplicatedStorage.PlotName.Value = plt
break
end
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
for _, plt in pairs(workspace.Plots:GetChildren()) do
if plt.Owner.Value ~= nil then
plt.Owner.Value = nil
else
end
end
end)
local players = game:GetService("Players")
local plotsFolder = workspace.Plots
local plots = plotsFolder:GetChildren()
players.PlayerAdded:Connect(function(player)
local plotValue = Instance.new("ObjectValue")
plotValue.Name = "Plot"
plotValue.Parent = player
local otherPlayers = players:GetPlayers()
for _, plot in ipairs(plots) do
for index, otherPlayer in ipairs(otherPlayers) do
if otherPlayer ~= player then
if otherPlayer.Plot then
if otherPlayer.Plot.Value then
if otherPlayer.Plot.Value == plot then
break
end
end
end
end
if index == #otherPlayers - 1 then
plotValue.Value = plot
end
end
end
end)