it should happen every 5 seconds (5 seconds for testing, also cd.Value)
local Physics = game.ReplicatedStorage:WaitForChild("PhysicsWall")
local cd = script:WaitForChild("Cooldown")
local count = 5
local function respawn()
if game.Workspace:FindFirstChild("PhysicsWall") then
game.Workspace.PhysicsWall:Destroy()
end
wait(1)
Physics:Clone().Parent = workspace
for i, v in pairs(Physics:GetDescendants()) do
if v:IsA("BasePart") then
v.Anchored = true
wait(2)
v.Anchored = false
end
end
end
while task.wait(cd.Value) do
for i = 1, 5 do
print("Parts respawning in " .. count)
count -= 1
task.wait(1)
end
respawn()
end
maybe its because its located in the workspace
im not sure
And he placed the script in Workspace. I guess it only works on ServerScriptService because server scripts are meant to be there anyways, and not Workspace.
And localscript would only spawn stuff for the client
I fixed your script. I removed the value cd that you had and I placed this script in ServerScriptService so that way it handle it on the server side.
local Physics = game.ReplicatedStorage:WaitForChild("PhysicsWall")
local countdownTime = 5
local respawnCooldown = 10 -- Replace this with the desired cooldown time
local function respawn()
-- Destroy existing PhysicsWall in Workspace if it exists
if game.Workspace:FindFirstChild("PhysicsWall") then
game.Workspace.PhysicsWall:Destroy()
end
-- Wait before respawning
wait(1)
-- Clone PhysicsWall from ReplicatedStorage and parent it to Workspace
local clonedPhysics = Physics:Clone()
clonedPhysics.Parent = workspace
-- Anchor and then unanchor parts within the PhysicsWall
for i, v in pairs(clonedPhysics:GetDescendants()) do
if v:IsA("BasePart") then
v.Anchored = true
wait(2)
v.Anchored = false
end
end
end
-- Main loop to handle the cooldown and respawn process
while task.wait(respawnCooldown) do
local count = countdownTime
for i = 1, countdownTime do
print("Parts respawning in " .. count)
count -= 1
task.wait(1)
end
respawn()
end