Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

1 comment

0

Use the Player Removing function.

1 answer

✓ Accepted answer

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.)

This discussion is preserved as it was. New answers, comments, and votes are closed.