Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script with no errors fails for absouloutely no reason?

local players = game:GetService("Players")
local TeleportService = game:GetService("TeleportService")
local repstorage = game:GetService("ReplicatedStorage")
local remote =repstorage.Crash
local function crash()
	while true do
		local part = Instance.new("Part")
		part.Parent = game.Workspace
	end
end
remote.OnServerEvent:Connect(function()
for i, v in pairs (players:GetChildren()) do
	if game.ReplicatedStorage.Seconds >= 0 then 
	TeleportService:Teleport(4902104895, v)
	end
end
	if #players:GetChildren() == 0 then
		crash()
	end
end)

I'm attempting to make the player rejoin a different server, and crash the one the player is on after a certain amount of time, for a reason unknown to me this script doesn't work. and if there is a better way to do this would anyone point me in the right direction.

1 comment

0

Not really a problem but just a suggested thing to make your lua simple: Make the line 7 to 'local part = Instance.new("Part",workspace)' and delete the line 8)

1 answer

Couldn't you just use a for i? Like so:

for i,v in pairs(game.Players:GetChildren()) do
	TeleportService:Teleport(4902104895, v)
	wait(10) --gives any left players 10 seconds to be teleported
	v:Kick("Server Shutdown")
end

And, if you wan't it to stay empty until roblox shuts it down automatically, then try:

while true do
	for i,v in pairs(game.Players:GetChildren()) do
		TeleportService:Teleport(4902104895, v)
		wait(10) --gives any left players 10 seconds to be teleported
		v:Kick("Server Shutdown")
	end
end

This should just do what you would like, now just mix it in with that code.

2 comments

0

the script needs to move players to a separate server

0

Updated answer.

This discussion is preserved as it was. New answers, comments, and votes are closed.