Hello developers! For the last 30 minutes, I have been trying to do this, and I’m thinking I would fire a remote event to all the clients and check if they have the sword or not, then break the loop if they don’t have the sword. Am I correct?
-- This is in a serverscript in serverscriptservice
for _, player in pairs(game.Players:GetChildren()) do
if player.Backpack.AzureSword == true or player.StarterGear.AzureSword == true then
player.Character.AzureSword:Destroy()
player.Backpack.AzureSword:Destroy()
player.StarterGear.AzureSword:Destroy()
else
break
end
end
If the player does not have a sword then the loop will just continue onto the next player? I think your getting confused on what break does. So in this case if the player does not have the sword it will stop the whole loop and continue with the code below it. Instead you would use continue to make the loop go onto the next key/value pair. But in this case the loop is going to automatically go through each player and if it does not have the sword it will just continue to the next player. And obviously listen to @DarkDanny04 to improve your code.
I would suggest you to do what @DarkDanny04 said to do (And another thing is that you wrote Charcter and not Character. Another thing is that when your script fires, the character might not been added yet)