ive done something like this but it doesn’t seem to work.
local Max_Number = 25
local Min_Number = 5
local Random = math.random(Min_Number, Max_Number)
wait(Random)
local Parts = game.Workspace.Floor1:GetChildren()
workspace.Floor1 = false
wait(4)
script.Parent:Destroy()
end
EDIT SORRY: I need to make a script that unanchors the parts within a model then deletes them after a certain amount of time)
local model = script.Parent -- Set script inside of Model or specify the location of model.
local min = 5
local max = 25
local RANDOM = math.random(min, max)
-- Unanchor the parts within the model
for _, part in ipairs(model:GetChildren()) do
if part:IsA("BasePart") then
part.Anchored = false
end
end
-- Wait for the specified amount of time
wait(RANDOM)
-- Delete the parts within the model
for _, part in ipairs(model:GetChildren()) do
if part:IsA("BasePart") then
part:Destroy()
end
end
local Max_Number = 25
local Min_Number = 5
task.wait(math.random(Min_Number,Max_Number)) -- use task.wait() instead of wait(), you also don't really need a variable
local Parts = workspace.Floor1:GetChildren()
for i, v in Parts do
if v:IsA("BasePart") then v.Anchored = false end
end
task.wait(4)
script.Parent:Destroy()
Im assuming that Floor1 is a model, then why are you setting it to false randomly? If you want to unanchor everything in the model, you loop through each part inside of it like this:
for index, object in ipairs(workspace.Floor1:GetChildren()) do
-- check if the current iteration is a BasePart, which is basically all types of parts
if object:IsA("BasePart") then
object.Anchored = false -- unanchor part
end
end