#Plot system
1 messages · Page 1 of 1 (latest)
HELLO
code pls
ok
script.Parent.SelectPlotFrame.Visible = false
local plots = workspace:WaitForChild("Plots")
local plotButton = script.Parent:WaitForChild("PlotButton")
local selectingPlot = false
local camera = workspace.CurrentCamera
local plotsToSelect = {}
local currentPlot = 1
local leftArrowConn = nil
local rightArrowConn = nil
local function updateCamera()
local plotModel = plotsToSelect[currentPlot]
if plotModel and plotModel.PrimaryPart then
local pos = plotModel.PrimaryPart.Position
local lookVector = plotModel.PrimaryPart.CFrame.LookVector
camera.CFrame = CFrame.new(pos + Vector3.new(0, 70, 0) + lookVector * 50, pos)
else
warn("PrimaryPart missing for plot: " .. (plotModel and plotModel.Name or "nil"))
end
end
local function setupPlotSelection()
local allPlots = plots:GetChildren()
table.sort(allPlots, function(a, b)
local numA = tonumber(a.Name:match("%d+")) or 0
local numB = tonumber(b.Name:match("%d+")) or 0
return numA < numB
end)
plotsToSelect = {}
for _, plot in ipairs(allPlots) do
if plot:FindFirstChild("Owner") and plot.Owner.Value == "" then
table.insert(plotsToSelect, plot)
end
end
currentPlot = 1
if #plotsToSelect == 0 then
script.Parent.SelectPlotFrame.PlotName.Text = "No plots available"
return
end
script.Parent.SelectPlotFrame.PlotName.Text = plotsToSelect[currentPlot].Name
updateCamera()
if leftArrowConn then leftArrowConn:Disconnect() end
if rightArrowConn then rightArrowConn:Disconnect() end
leftArrowConn = script.Parent.SelectPlotFrame.LeftArrow.MouseButton1Click:Connect(function()
currentPlot = currentPlot - 1
if currentPlot < 1 then currentPlot = #plotsToSelect end
script.Parent.SelectPlotFrame.PlotName.Text = plotsToSelect[currentPlot].Name
updateCamera()
end)
rightArrowConn = script.Parent.SelectPlotFrame.RightArrow.MouseButton1Click:Connect(function()
currentPlot = currentPlot + 1
if currentPlot > #plotsToSelect then currentPlot = 1 end
script.Parent.SelectPlotFrame.PlotName.Text = plotsToSelect[currentPlot].Name
updateCamera()
end)
end
plotButton.MouseButton1Click:Connect(function()
local ownedPlot = nil
for _, plot in pairs(plots:GetChildren()) do
if tonumber(plot.Owner.Value) == game.Players.LocalPlayer.UserId then
ownedPlot = plot
break
end
end
if ownedPlot then
game.ReplicatedStorage.PlotSystemRE:FireServer("removePlot")
plotButton.Text = "PLOTS"
selectingPlot = false
script.Parent.SelectPlotFrame.Visible = false
camera.CameraType = Enum.CameraType.Custom
else
selectingPlot = not selectingPlot
if selectingPlot then
camera.CameraType = Enum.CameraType.Scriptable
setupPlotSelection()
script.Parent.SelectPlotFrame.Visible = true
else
camera.CameraType = Enum.CameraType.Custom
script.Parent.SelectPlotFrame.Visible = false
-- Disconnect arrow events to avoid stacking
if leftArrowConn then leftArrowConn:Disconnect() leftArrowConn = nil end
if rightArrowConn then rightArrowConn:Disconnect() rightArrowConn = nil end
end
end
end)
script.Parent.SelectPlotFrame.SelectPlotButton.MouseButton1Click:Connect(function()
if #plotsToSelect > 0 then
game.ReplicatedStorage.PlotSystemRE:FireServer("buyPlot", plotsToSelect[currentPlot].Name)
else
warn("No plot selected to buy.")
end
end)
game.ReplicatedStorage.PlotSystemRE.OnClientEvent:Connect(function(instruction)
if instruction == "plotBought" or instruction == "plotRemoved" then
plotButton.Text = "SELL PLOT"
selectingPlot = false
camera.CameraType = Enum.CameraType.Custom
script.Parent.SelectPlotFrame.Visible = false
end
end)
Is there a specific way to send mb if there is
wait gimme a sec
there
** You are now Level 1! **
there is also this:
local plots = workspace:WaitForChild("Plots")
local re = game.ReplicatedStorage:WaitForChild("PlotSystemRE")
for _, plot in pairs(plots:GetChildren()) do
if not plot:FindFirstChild("Owner") then
local ownerValue = Instance.new("StringValue")
ownerValue.Name = "Owner"
ownerValue.Value = ""
ownerValue.Parent = plot
end
end
re.OnServerEvent:Connect(function(plr, instruction, plotName)
if instruction == "removePlot" then
local playerPlot = nil
for _, plot in pairs(plots:GetChildren()) do
if tonumber(plot.Owner.Value) == plr.UserId then
playerPlot = plot
break
end
end
if playerPlot then
playerPlot.Owner.Value = ""
print(plr.Name .. " removed their plot: " .. playerPlot.Name)
end
elseif instruction == "buyPlot" then
local plot = plots:FindFirstChild(plotName)
if plot and plot.Owner.Value == "" then
plot.Owner.Value = tostring(plr.UserId)
print(plr.Name .. " claimed plot: " .. plot.Name)
local character = plr.Character
if character and character:FindFirstChild("HumanoidRootPart") and plot.PrimaryPart then
character.HumanoidRootPart.CFrame = plot.PrimaryPart.CFrame + Vector3.new(0, 10, 0)
else
warn("Could not teleport " .. plr.Name .. " to plot: missing character parts or plot.PrimaryPart")
end
re:FireClient(plr)
else
warn("Plot " .. tostring(plotName) .. " is already owned or does not exist")
end
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
for _, plot in pairs(plots:GetChildren()) do
if tonumber(plot.Owner.Value) == plr.UserId then
plot.Owner.Value = ""
print(plr.Name .. "'s plot " .. plot.Name .. " has been freed because they left the game")
end
end
end)
my friend said it would just tp them to plot and remove option to "claim" it
@earnest swift
yeah
maybe ask your friend about this issue since they're the one who wrote this code and understand it better?
ok
is your friend chatgpt?
nah
lol just pulling your nuts