Players can destroy things in my game and I want them to go back to normal every 5 minutes
You can clone model and parent it to serverstorage or nil and spawn it later.
For this, you’ll need to store the group of objects in a secure location, such as ServerStorage. This will be the template.
Then, every five minutes, you’ll want to clear whatever destroyed items are already in Workspace, and then clone the template clone it to Workspace.
Here’s a quick example I just made.
local workspace = game:GetService("Workspace")
local template = game:GetService("ServerStorage"):WaitForChild("ToDestory")
while true do
if workspace:FindFirstChild("ToDestroy") then
workspace.ToDestroy:Destroy()
end
local newObjects = template:Clone()
newObjects.Parent = workspace
wait(60 * 5)
end
So, this would copy the whole map into serverstorage? Or do I have to do that beforehand?
You only actually need to put the parts that can be changed by player actions in a storage location which you can swap out for the current copy every now and again. Refreshing the whole map will incur unnecessary internal costs for you.
By the way; in the future, this is something you should attempt yourself first before posting. You can also figure out these minor details on your own. It’d be more appreciated if you were asking on an attempt rather than for someone to supply the code for you. Define your requirements, then set out to code. You can use various references for learning certain things as well, such as how to run an action after a period of time repeatedly.
You need to place the map into ServerStorage
, for the script to work. You’d also need to either change the map’s name to ToDestroy
or replace it with the name of your map in the script.