Hello, i have this issue where when my players joins a plot the part i want turns visible, but i only want the part to become visible when that plot is joined, because at the moment for example:
plot9>part (the part needs to become visible when plot9 is joined)
Joined>plot9>part = visible.
but now when you join a other plot. the part of the other plot becomes visible.
Joined>plot8>plot9>part = visible.
I want every plot up until 10 to make it so when a player joins a random plot, a part that is on that plot becomes visible.
so the part in plot1 becomes visible only when plot1 is joined. and not 2, 3, 4, 5, 6, 7, 8, 9 or 10.
and i want it for each individual plot but cant do it, if you can help please do.
here is my script:
local plots = workspace:WaitForChild("Plots")
for i, plot in pairs(plots:GetChildren()) do
local ownerValue = Instance.new("StringValue", plot)
ownerValue.Name = "Owner"
end
local re = game.ReplicatedStorage:WaitForChild("PlotSystemRE")
re.OnServerEvent:Connect(function(plr, instruction, plotName)
if instruction == "removePlot" then
local playerPlot = nil
for i, plot in pairs(plots:GetChildren()) do
if tonumber(plot.Owner.Value) == plr.UserId then
playerPlot = plot
end
end
if playerPlot then
playerPlot.Owner.Value = ""
end
elseif instruction == "buyPlot" then
if plots:FindFirstChild(plotName) and plots[plotName].Owner.Value == "" then
plots[plotName].Owner.Value = plr.UserId
re:FireClient(plr)
plr.Character.HumanoidRootPart.CFrame = plots[plotName].CFrame + Vector3.new(0, 10, 0)
local descendants = plots:GetDescendants()
for i=1, #descendants do
local plote = descendants[i]
if plote.Name == "MainPlotFrame" then
plote.Transparency = 0
end
end
end
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
for i, plot in pairs(plots:GetChildren()) do
if tonumber(plot.Owner.Value) == plr.UserId then
plot.Owner.Value = ""
end
end
end)
here is my local script:
script.Parent.SelectPlotFrame.Visible = false
local plots = workspace.Plots
local plotButton = script.Parent:WaitForChild("PlotButton")
local selectingPlot = false
local camera = workspace.CurrentCamera
plotButton.MouseButton1Click:Connect(function()
local ownedPlot = nil
for i, plot in pairs(plots:GetChildren()) do
if tonumber(plot.Owner.Value) == game.Players.LocalPlayer.UserId then
ownedPlot = plot
end
end
if ownedPlot then
game.ReplicatedStorage.PlotSystemRE:FireServer("removePlot")
plotButton.Text = "PLOTS"
selectingPlot = false
script.Parent.SelectPlotFrame.Visible = false
else
selectingPlot = not selectingPlot
if selectingPlot then
camera.CameraType = Enum.CameraType.Scriptable
local plotsToSelect = {}
for i, plot in pairs(plots:GetChildren()) do
if plot.Owner.Value == "" then
table.insert(plotsToSelect, plot)
end
end
local currentPlot = 1
script.Parent.SelectPlotFrame.PlotName.Text = plotsToSelect[currentPlot].Name
camera.CFrame = CFrame.new(plotsToSelect[currentPlot].Position + Vector3.new(0, 70, 0) + plotsToSelect[currentPlot].CFrame.LookVector * 50, plotsToSelect[currentPlot].Position)
script.Parent.SelectPlotFrame.LeftArrow.MouseButton1Click:Connect(function()
currentPlot -= 1
if currentPlot == 0 then currentPlot = #plotsToSelect end
script.Parent.SelectPlotFrame.PlotName.Text = plotsToSelect[currentPlot].Name
camera.CFrame = CFrame.new(plotsToSelect[currentPlot].Position + Vector3.new(0, 70, 0) + plotsToSelect[currentPlot].CFrame.LookVector * 50, plotsToSelect[currentPlot].Position)
end)
script.Parent.SelectPlotFrame.RightArrow.MouseButton1Click:Connect(function()
currentPlot += 1
if currentPlot == #plotsToSelect + 1 then currentPlot = 1 end
script.Parent.SelectPlotFrame.PlotName.Text = plotsToSelect[currentPlot].Name
camera.CFrame = CFrame.new(plotsToSelect[currentPlot].Position + Vector3.new(0, 70, 0) + plotsToSelect[currentPlot].CFrame.LookVector * 50, plotsToSelect[currentPlot].Position)
end)
script.Parent.SelectPlotFrame.Visible = true
else
camera.CameraType = Enum.CameraType.Custom
script.Parent.SelectPlotFrame.Visible = false
end
end
end)
script.Parent.SelectPlotFrame.SelectPlotButton.MouseButton1Click:Connect(function()
game.ReplicatedStorage.PlotSystemRE:FireServer("buyPlot", script.Parent.SelectPlotFrame.PlotName.Text)
end)
game.ReplicatedStorage.PlotSystemRE.OnClientEvent:Connect(function(instruction)
plotButton.Text = "P"
selectingPlot = false
camera.CameraType = Enum.CameraType.Custom
script.Parent.SelectPlotFrame.Visible = false
script.Parent.Enabled = false
end)
here is my remote event:
here is my script parent:
here is my local script parent:
and here is my folder:
please do note that every single plot has a child that i want to turn visible only when that plot is joined.