Player is sitting in a seat, but my script says they are not sitting there and it says they are sitting there

This strange bug has been killing me for the past 3 days because no matter what I do, it does not fix it. When I playtest the game in-studio, this bug does not occur at all, and this COMPLETELY Works. but when I am playing my game in Roblox, it does not work but it does in the studio. Basically, the script checks who is sitting in the seats and if they are, they are counted as a winner. If they are not, they are counted as dead. I added prints to see what my response would be but I was shocked when they both printed if they sat down. I really need help with this and not knowing how to fix this is eating me away. Thank you so much for reading.

Script:

for i = 1, #people do 
	if people[i].Dead.Value == false then
		if workspace:FindFirstChild("Rescue"..game.ReplicatedStorage.GM.RescueType.Value) then
			for _, seat in next, workspace:FindFirstChild("Rescue"..game.ReplicatedStorage.GM.RescueType.Value):FindFirstChildOfClass("Model"):GetChildren() do
				if seat:IsA("Seat") and seat.Occupant then
					if seat.Occupant.Parent == people[i].Character then
						print(people[i].Name.." is in the heli, they made it.")
						if game.ReplicatedStorage.GM.Winners.Value == "The Survivors are:" then
							game.ReplicatedStorage.GM.Winners.Value = game.ReplicatedStorage.GM.Winners.Value.." "..people[i].Name
						else
							game.ReplicatedStorage.GM.Winners.Value = game.ReplicatedStorage.GM.Winners.Value..", "..people[i].Name
						end
					elseif people[i].Character ~= seat.Occupant.Parent then
						people[i].Dead.Value = true
						print(people[i].Name.." did not make it to the heli!")
					end
				end
			end
		end
	end
end

Output:
image

1 Like

PERHAP :sweat_smile:

--for i = 1, #people do 
	--if people[i].Dead.Value == false then
		if workspace:FindFirstChild("Rescue"..game.ReplicatedStorage.GM.RescueType.Value) then
			for _, seat in next, workspace:FindFirstChild("Rescue"..game.ReplicatedStorage.GM.RescueType.Value):FindFirstChildOfClass("Model"):GetChildren() do
				if seat:IsA("Seat") and seat.Occupant then
					local player = game.Players:GetPlayerFromCharacter(seat.Occupant.Parent)
				   if table.find(people,player) then
						print(player.Name.." is in the heli, they made it.")
						if game.ReplicatedStorage.GM.Winners.Value == "The Survivors are:" then
							game.ReplicatedStorage.GM.Winners.Value = game.ReplicatedStorage.GM.Winners.Value.." "..player.Name
						else
							game.ReplicatedStorage.GM.Winners.Value = game.ReplicatedStorage.GM.Winners.Value..", "..player.Name
						end
					else
						player.Dead.Value = true
						print(player.Name.." did not make it to the heli!")
					end
				end
			end
		end
	--end
--end

if it doesn’t work just forget my effort :ghost:

1 Like

It kinda works but players who aren’t in the seats are still winning which means the else statement doesn’t do its purpose.

that’s all i can help :slight_smile:

--for i = 1, #people do 
--if people[i].Dead.Value == false then
if workspace:FindFirstChild("Rescue"..game.ReplicatedStorage.GM.RescueType.Value) then
	for _, seat in next, workspace:FindFirstChild("Rescue"..game.ReplicatedStorage.GM.RescueType.Value):FindFirstChildOfClass("Model"):GetChildren() do
		if seat:IsA("Seat") and seat.Occupant then
			local player = game.Players:GetPlayerFromCharacter(seat.Occupant.Parent)
			local foundIndex = table.find(people,player)
			if foundIndex then
				table.remove(people,foundIndex)--that's mean the only players that left inside table are considered dead
				print(player.Name.." is in the heli, they made it.")
				if game.ReplicatedStorage.GM.Winners.Value == "The Survivors are:" then
					game.ReplicatedStorage.GM.Winners.Value = game.ReplicatedStorage.GM.Winners.Value.." "..player.Name
				else
					game.ReplicatedStorage.GM.Winners.Value = game.ReplicatedStorage.GM.Winners.Value..", "..player.Name
				end
			end
		end
	end
end
--end
--end
for i = 1, #people do 
	if people[i]:IsDescendantOf(game.Players) then
		player.Dead.Value = true
		print(player.Name.." did not make it to the heli!")
	else 
		print(people[i].." Left The Game!)
	end
end

@Stickpuppet

1 Like

I will check this out when I get home later!

image
this is the line
image