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

How to make a main game algorithm?

I am making a fairly large game called "Juggernaut", but I have a bug that the "main algorithm", the part that runs when people get teleported to the map and they actually play. They do get teleported to map and get weapons like how I coded it, but the thing is when someone dies nothing happens, and they just spawn in the lobby, and one part works, when they die they do get a boolean variable named "alive" set to false, but the code doesn't react to that. Here's my "main game" code:~~~~~~~~~~~~~~~~~ for y=1, 600 do

wait(1)
Workspace.numberofplayers.Value = 0
for _, v in pairs(game.Players:GetChildren()) do
	repeat wait() until v.Character~=nil and v~=nil
	if v.alive.Value == true then
		Workspace.numberofplayers.Value = Workspace.numberofplayers.Value + 1
	end
	
end
while game.Players.NumPlayers < 2 or game.Workspace.numberofplayers.Value < 2 do
	b = true
end


if Workspace.numberofplayers.Value == 1 then
	for _,v in pairs(game.Players:GetChildren()) do
		if v~=nil and v.Character~=nil then
			if v.alive.Value == true then
				b = true
				local msg3 = Instance.new("Message", game.Workspace)
				msg3.Text=v.Name .. " has won!"
				wait(5)
				msg3:remove()
				for _, v in pairs(game.Players:GetChildren()) do
					v.Character:BreakJoints()
				end	
				break
			end
		end
		if b == true then break end
		i = i + 1
	end
	if b == true then break end
end
if b == true then break end

end


1 answer

Instead of creating your own variable for the number of players use..

game.Players.NumPlayers

1 comment

0

I do know that, but I need to make sure that everyone that is in game.Workspace.numberofplayers.Value is alive.

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