So the local script makes a folder when a player joins but I can get it to remove the folder that is made in the beginning when the player leaves and the folder is the same name when the player joins and I want it just to destroy the folder that was created when that player joined

I already tried this

game.Players.PlayerRemoving:connect(function)
    Folder:Destroy()
end)

The Script

local Folder = Instance.new("Folder")
Folder.Parent = workspace
Folder.Name = "Parts"

local draw = function(target, source, color)
	local mag = (source - target).magnitude
	local Part = Instance.new("Part")
	Part.Anchored = true
	Part.CanCollide = false
	Part.Locked = true
	Part.TopSurface = Enum.SurfaceType.Smooth
	Part.BottomSurface = Enum.SurfaceType.Smooth
	Part.FormFactor = Enum.FormFactor.Custom
	Part.Size = Pallete.Size * Vector3.new(1, 1, mag)
	Part.CFrame = CFrame.new(source, target) *CFrame.new(0, 0, -mag/2)
	Part.Transparency = 1
	for i = 1, 6 do
		local SurfaceGui = Instance.new("SurfaceGui")
		SurfaceGui.Parent = Part
		SurfaceGui.Face = EnumFaces[i]
		local Frame = Instance.new("Frame")
		Frame.BackgroundColor3 = Pallete.Color
		Frame.BorderColor3 = Pallete.Color
		Frame.Size = UDim2.new(1, 0, 1, 0)
		Frame.Parent = SurfaceGui
	end
	Part.Parent = Folder
	Cache[#Cache + 1] = Part
end

2 comments

0

If your game is filtering enabled then the folder only exists on their client anyway, so there is no need to destroy it.

0

Ooo, never thought about that and never knew what was filtering enabled was for ?