Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i make this remove the player's Building when player leaves?

Asked by 4 years ago

So like i am making a Placement system which is almost complete all i need is to know how to remove the player's who left itemholder folder child's Like

To get the Plot's Item holder folder it be like

Plot.PlacedObjects but how do i make it remove all the items instead of like 1?

Code--

local player = game:GetService("Players")

local plots = workspace.Plots

local function FindPlot(plr)
    local plotChildren = plots:GetChildren()

for i,plt in pairs(plotChildren) do
if plt then
    if plt.Plot.Owner.Value ~= nil then
        print("Owner Found!")
    else
        local pltNm = plt.Name

        game.ReplicatedStorage.Events.ClientPlot:FireClient(plr, pltNm)

        plt.Plot.Owner.Value = plr

        break
    end
end
end
end
player.PlayerAdded:Connect(FindPlot)
0
Use the Player Removing function. namespace25 594 — 4y

1 answer

Log in to vote
1
Answered by
Upbolt 20
4 years ago

Create a PlayerRemoving event; upon firing, call Delete on the object. (If there are multiple objects, I recommend sticking them all into a single container.)

Ad

Answer this question