just as writen how can i fire all the clients that has a specific attribute ??
right now i fire just one client that has that specific attribute
for innocentsCounter, Innocents in pairs(playersinsession) do
if Innocents:GetAttribute("Innocent") == true and Innocents:GetAttribute("Killer") == false then
game.ReplicatedStorage.GameplayEvents.MorpherCutscene:FireAllClients(Innocent)
end
end
You have already looped through all the players in the session and you have checked for their “Innocent” attribute. Now, rather than firing to ALL the clients, you just need to fire to the “Innocents” client, since it meets all your criteria. Change “FireAllClients” to “FireClient” and you should be set!
If it’s not firing to all the clients at the same time, that means there could be a function within your for loop that is yielding. Is there more to this code that you have taken out?
well i got tweens if that is considered a functions and as i expected the code didnt fire all the clients at the same time it waited for the fired client to finish and then fire the other
edited because i forgot something
the tweens arent in a function it is just a tween:Play()
Try wrapping the code within your for loop within a task.spawn, which basically runs functions within your for loop simultaneously.
for innocentsCounter, Innocents in pairs(playersinsession) do
task.spawn(function()
if Innocents:GetAttribute("Innocent") == true and Innocents:GetAttribute("Killer") == false then
game.ReplicatedStorage.GameplayEvents.MorpherCutscene:FireAllClients(Innocent)
end
-- EVERYTHING ELSE YOU HAVE
end)
end
If the player is innocent, then no need to check for :GetAttribute(“Killer”). However, if you want to, you can change your conditional statement to:
if Innocents:GetAttribute("Innocent") == true and not Innocents:GetAttribute("Killer") then
This will account for players who have the “Innocent” attribute and either DON’T HAVE the “Killer” attribute or the “Killer” attribute is set to false. The “not” keyword checks BOTH for whether the attribute is nil or false!