-
What do you want to achieve?
I want to make a system that reset everything in the server.
Because in my game i have an explosion that destroys all the map and instead of kicking all players i want a system that reset everything and players can play again without rejoining. -
What is the issue?
I don’t know how to do it. -
What solutions have you tried so far?
I searched for years on forums, videos, and i found nothing.
https://developer.roblox.com/en-us/api-reference/class/TeleportService
Get the whole server, and then teleport them all into a new instance of your game. If you are making a round-based system, that will require more coding on your part to manually refresh the whole map.
Thank you for your reply, i already take a look at this but i don’t know how to really do it
I did a system with that but some players was not getting teleported so i didn’t know where the issue came from
It would go something like this
local TPService = game:GetService("TeleportService");
local players = game.Players:GetPlayers();
local place = 0; --Change with the placeID
local x,y = pcall(function() --x is whether is was a success, y is their destination
return TPService:TeleportPartyAsync(players, place);
end);
--Make sure you wrap it in a pcall, as there is a chance TeleportService may fail.
if x then
print("Success!");
else
--you can make a retry system here, this is where the script leads to if the teleportation has failed
end;
And is this script compatible with vip servers?
Like if it’s a VIP server it teleport back to the vip server?
You can kind of achieve this by using a mixture of variables and ReservedServers (TeleportService | Roblox Creator Documentation) but players joining the VIP server may not end up with the players in the reserved server because of roblox api restrictions
Okay, i know a game that i think don’t use TeleportService for the reset system. Like you hear the sounds replaying in background with a blackscreen. Do you have any ideas how they can do that ?
They would probably be manually using a lot of code to refresh the server themselves
It would go through the entire game, wipe a folder or model in the workspace containing the map, and create a new one.
Here is the best short example I can give of this based on how you described your problem
local everything = Instance.new("Folder");
everything.Parent = workspace;
everything.Name = "Map";
--place the map inside here
local map = nil; --Direct this to a copy of the map
function reset()
for _,v in pairs(everything:GetChildren()) do --could lag, in that case uncomment the next line
--wait(.1);
v:Destroy();
end;
return "Complete";
end;
function rebuild()
map:Clone().Parent = everything;
for _,v in pairs(game.Players:GetPlayers()) do
v:LoadCharacter();
end;
return "Rebuilt and respawned";
end;
Yes but how do i place the map inside Map if the folder isn’t created
Create it in the workspace beforehand instead and name it Map, place the map in and make a copy of it in ReplicatedStorage
Does this affect the game performance ?
It shouldn’t, but if it does you can add a wait() inside of the reset() loop
Okay, thank you i will try that
But if i have scripts in other things like server script service and stuff how do i reset them?
That would require manually putting in the support yourself to do that. I can’t really put it in for you, you would just have to make it know when to reset upon the server being reset
You could try making a Master script that disables and deletes all of the old ones and replaces them with new ones