So I'm making a survival horror game and I need it so it can somehow know if a player has escaped to a player being killed. The script checking if there are no players in a team is below. Please help!

if #teamplayers == 0 then
	for _, v in pairs(game.Players:GetChildren()) do
		if v.TeamColor == BrickColor.new("Carnation pink") then
			v.leaderstats.Cash.Value = v.leaderstats.Cash.Value + 100
			v.CharacterAppearanceId = v.UserId
			v.TeamColor = BrickColor.new("White")
			v.CharacterAppearanceId = v.UserId
			print("eeeee")
			game.ReplicatedStorage.ESallyhasWon:FireAllClients()
			wait(3)
			
			script.CountDown.Value = 0
		end
	end
end

6 comments

0

any output errors?

0

There's nothing wrong with the script. I just need ideas on how it would work. What I mean is I need the script to somehow know between a player dying and a player escaping.

0

So if you're wanting to separate players in any way, I'd would either use a set of tables to store the different playerstates or use CollectionService to tag players.

0

Thanks! I'll definitely try using tables.

0

Well, is it possible for tables to be in modulescripts so multiple scripts can access it?

0

Maybe you could make a title related to the script, not the game though.