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

How can I make the player spawn again at a certain spawn after 3 "Waves"?

Ok so the part for the map spawnpoint (player's spawnpoint) is named as "Spawn", I need help on how to make the players spawn again after a few certain waves.

local roundMsg = game.ReplicatedStorage.Values:WaitForChild("roundMsg")
local zombieCount = game.ReplicatedStorage.Values:WaitForChild("zombiesRemaining")
local zombiesAlive = game.ReplicatedStorage.Values:WaitForChild("zombiesAlive")
local gameInProgress = game.ReplicatedStorage.Values:WaitForChild("gameInProgress")
local wave = game.ReplicatedStorage.Values:WaitForChild("Wave")
local collectionservice = game:GetService("CollectionService")


while true do
	for i = 10,0,-1 do
		roundMsg.Value = "Intermission: "..i
		if i == 1 then
			local map = math.random(1,7)
			if map == 1 then
				game.ReplicatedStorage.Maps.CornFarm:Clone().Parent = workspace.Map
			end
			if map == 2 then
				game.ReplicatedStorage.Maps.Subway:Clone().Parent = workspace.Map
			end
			for i, v in pairs(workspace.Map:FindFirstChildOfClass("Model"):GetChildren()) do
				if v.Name == "Spawner" then
					collectionservice:AddTag(v, "Spawner")
					end
				end
			for i, v in pairs(game.Players:GetPlayers()) do
				collectionservice:AddTag(v.Character, "Alive")
				v.Character.Torso.CFrame = workspace.Map:FindFirstChildOfClass("Model").Spawn.CFrame
			end
			roundMsg.Value = "Round in Progress"
			zombieCount.Value = 6
			zombiesAlive.Value = 6
			wave.Value = 1
			gameInProgress.Value = true
			repeat
				if #collectionservice:GetTagged("Alive") > 0 then
					if zombiesAlive.Value == 0 then
						wave.Value = wave.Value + 1
						zombieCount.Value = 6 * wave.Value
						zombiesAlive.Value = 6 * wave.Value
					end
					elseif #collectionservice:GetTagged("Alive") == 0 then
					gameInProgress.Value = false
				end
				wait(1)
			until gameInProgress.Value == false
				workspace.Map:ClearAllChildren()
		end
	wait(1)
	end
end

Alright so here is the main script for my game so far but I'm having trouble on how to make the players spawn again after a few certain waves

1 answer

Running off the top of my head you'll want to make use of two things. 1. You'll want to disable the CharacterAutoLoads feature found under every player. A quick example being:

game:GetService("Players").PlayerAdded:Connect(function(plr)
	plr.CharacterAutoLoads = false
end)

And 2. You'll want to use the Player:LoadCharacter() feature which does what it says on the tin. So for each player that isn't currently alive you can use LoadCharacter on them after the respawn requirements you want to set in place are met.

3 comments

0

Alright my good sir, where should I place your written script?

0

It really just depends on how you prefer to organize your scripts but me personally, I would put it in a script by itself in the ServerScriptService.

0

Simpletton, my advice is don't copy his script and use it for your own purposes. That will teach you nothing really take a moment to understand what he just said and showed you and attempt it yourself. This site in general is here to help any questions you may have feel free to post.

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