In my game, which is a simple battle royale, it uses a map system. Everything in the game, including this script in question, runs fine until it loads the map and announces so in the Stringvalue (called Status and is located in ReplicatedStorage), which happens in lines 37-44. I suspect the error may be located at or below those lines. I was using a studio test server and there were no error messages in the output. The map and string value just sit there doing nothing once the map loads and the status value changes, making the script come to a halt. The script in question is located in ServerScriptService and every other script works just fine. The error may be located at or below lines 37-44

-- Define Variables

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local ServerStorage = game:GetService("ServerStorage")

local MapsFolder = ServerStorage:WaitForChild("Maps")

local Status = ReplicatedStorage:WaitForChild("Status")

local GameLength = 150

local reward = 1

--Game Loop

while true do
	
	Status.Value = "More players are needed to begin!"
	
	repeat wait(1) until game.Players.NumPlayers >= 2
	
	Status.Value = "Wait for the next battle!"
	
	wait(15)
	
	local plrs = {}
	
	for i, player in pairs(game.Players:GetPlayers()) do
		if player then
			table.insert(plrs,player) --add each player into plrs table
		end
	end
	
	wait(2)
	
	local AvailableMaps = MapsFolder:GetChildren()
	
	local ChosenMap = AvailableMaps[math.random(1,#AvailableMaps)]
	
	Status.Value = ChosenMap.Name.." was chosen!"
	
	local ClonedMap = ChosenMap:Clone()
	ClonedMap.Parent = workspace
	
	--teleport players to the map
	
	local SpawnPoints = ClonedMap:FindFirstChild("SpawnPoints")
	
	if not SpawnPoints then
		print("Spawnpoints not found")
	end
	
	local AvailableSpawnPoints = SpawnPoints:GetChildren()
	
	for i, player in pairs(plrs) do
		if player then
			character = player.Character
			
			if character then
				--teleport them
				
				character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[1]
				table.remove(AvailableSpawnPoints,1)
				
				
				--give them a sword
				
				local Sword = ServerStorage.Sword:Clone()
				Sword.Parent = player.Backpack

				local GameTag = Instance.new("BoolValue")
				GameTag.Name = "GameTag"
				GameTag.Parent = player.Character
				
			else
				--there is no character
				if not player then
					table.remove(plrs,i)
				end
			end
		end
	end


	Status.Value = "Get ready to rumble!"
	
	wait(2)
	
	for i = GameLength,0,-1 do
		
		for x, player in pairs(plrs) do
			if player then
				
				Character = player.Character
				
				if not character then
					--left the game
				else
					if character:FindFirstChild("GameTag") then
						--they are still alive
						print(player.Name.." is still in the game!")
					else
						--They are dead
						table.remove(plrs,x)
						print (player.Name.." has been removed.")
					end
				end
			else
				table.remove(plrs,x)
				print (player.Name.." has been removed.")
			end
		end
		
	Status.Value = "There are "..i.." seconds left until a draw, and "..#plrs.." players left!"
	
	if #plrs == 1 then
		--last person standing got that epic victory royale
		Status.Value = "The #1 victory royale goes to "..plrs[1].Name
		plrs[1].leaderstats.Points.Value = plrs[1].leaderstats.Points.Value + reward
		break
	elseif #plrs == 0 then
		Status.Value = "You all lost and got the #2 victory royale!"
		break
	elseif i == 0 then
		Status.Value = "Time is up! You alllost and got the #2 victory royale!"
		break
	end
	
		wait(1)
	end
	
	print("End of game.")
	
	for i, player in pairs(game.Players:GetPlayers()) do
		character = player.Character
		
		if not character then
			--ignore them
		else
			if character:FindFirstChild("GameTag") then
				character.GameTag:Destroy()
			end
			
			if player.Backpack:FindFirstChild("Sword") then
				player.Backpack.Sword:Destroy()
			end
			
			if character.Backpack:FindFirstChild("Sword") then
				character.Sword:Destroy()
			end	
			
		end
		
		player:LoadCharacter()
	end
	
	ClonedMap:Destroy()
	
	Status.Value = "The battle royale has concluded!"
	
	wait(2)
end

5 comments

0

The site is for getting help on scripts YOU made, not ones by alvinbloxx https://www.youtube.com/watch?v=5AUP9C0rtBY And his code sucks.

0

Not to get off topic here, but I only came here to fix a script. And yes, the code does come from Alvinbloxx, but it's a scripting tutorial, he allows people to type it along with him to learn. I knew my version of the script had an error, so I came here for help, and to learn what I did wrong. I am sorry if this query has brought you anger, but I only came here to learn where I messed up.

0

https://scriptinghelpers.org/help/community-guidelines Quoting the community guidelines, "Attempts should be your own work. Don't take a free model and expect us to fix it.^" Even if it is not from a free model, it is not your attempt.

0

I get your standpoint, but that same guide was marked with a ^ meaning that it should be up to the community wether or not this fits the site, but I do see your point, but this was my attempt at a script made by alvinblox, even if both scripts are identical.

0

:face_palm: