Im making a script that spawn a Throne in front of me, but sometimes when i die, it bug and i can spawn 2 thrones a time, i made a script that "when i press B, it spawn, when i press B again, it :Destroy", but when existe 2 of it, my script only destroy 1, i made a for to search all Workspace items with the Throne name, but its not working, wt im making wrong?
For Script:
if throneExists then for _, v in pairs(game.Workspace:FindFirstChild("BaragganThroneRemote")) do v:Destroy() wait(.1) end else local clone = model:Clone() clone.Parent = workspace clone:PivotTo(character.HumanoidRootPart.CFrame * CFrame.new(0, 1.3, 0) * CFrame.Angles(math.rad(180), math.rad(90), math.rad(0))) end
Add a ":GetChildren()" to get all the Childs of a Parent
for i,v in pairs (game.Workspace:FindFirstChild("BaragganThroneRemote"):GetChildren()) do v:Destroy() wait(0.1) end