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

Script pauses with out an error message?

I have this script that is supposed to collect player votes, sort them and figure out who the 2 people with the most votes were. This script works up until it’s supposed to name off the 2 players, where it just pauses. There is no error in the output screen and I’m not really sure what to do. The variable “vote” in the remote event is a player instance that gets sent from the client. The local script gets the player from game.Players itself.

	local readTable = {}
	local votes = {}
	for _, plr in ipairs(game.Teams.Players:GetPlayers()) do
		table.insert(votes, {plr, 0})
	end
	
	client.VoteSent.OnServerEvent:Connect(function(player,vote,nickname)
		for i, v in ipairs(votes) do
			if v[1] == vote then
				v[2] += 1
			end
		end
		readTable[player.NameItems.Nickname.Value] = nickname
	end)
	
	wait(30)
	
	for _, plr in ipairs(votingPlayers) do
		server.RecallAllVotes:FireClient(plr)
	end
	
	table.sort(votes, function(a,b)
		return a[2] > b[2]
	end)
	
	displayText("All votes have been cast. Let's see the results.")
	wait(6)
	for plr, vote in pairs(readTable) do
		displayText(plr .. " has voted for " .. vote .. ".")
		wait(4)
	end
	
	displayText("The two players who are at risk of elimination are...")
	wait(8.5)
--This is where it pauses
	displayText(votes[1].NameItems.Nickname.Value .. " and " .. votes[2].NameItems.Nickname.Value .. ".")
	
	votes[1].Team = game.Teams["Elimination Trial"]
	votes[2].Team = game.Teams["Elimination Trial"]
	

2 comments

1

your script is not working

0

obviously

1 answer

Try Putting At The Top Of Your Script Then Try

repeat wait() until table.getn(game.Players:GetPlayers()) > 1

2 comments

0

an earlier part of the script that I didn't show already makes sure there's more than 1 player in the game, so i don't think its that

0

Ok I'll Think Of Something

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