local CollectionService = game:GetService("CollectionService")
local cd = false
for _,part in pairs(game.ReplicatedStorage:WaitForChild("RebirthPortals"):GetDescendants()) do
if part:IsA("BasePart") then
CollectionService:AddTag(part,"RebirthPortalTag")
end
end
local function setupPortal(part)
if not part:IsDescendantOf(workspace) then return end
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and not cd then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
player.leaderstats.Rebirths.Value += 1
print("this ea")
part.Parent:Destroy()
cd = true
task.delay(5,function()
cd = false
end)
end
end)
end
for _,part in pairs(CollectionService:GetTagged("RebirthPortalTag")) do
setupPortal(part)
end
CollectionService:GetInstanceAddedSignal("RebirthPortalTag"):Connect(function(part)
setupPortal(part)
end)