How would I make the script go through all the players, and effect all of them? (Global script in the Workspace) Here's two things I tried:
for I,v in pairs(game.Players:GetPlayers()) do local randomCoor = coordinates[math.random(#coordinates)] local knife = game.ServerStorage.Knife:Clone() knife.Parent = v:WaitForChild("Backpack") game.Workspace.lobby.timer.SurfaceGui.timelft.Text = "Round In Progress..." c = v.Character or v.CharacterAdded:wait() c.Torso.CFrame = CFrame.new(randomCoor) wait(60) for I,v in pairs(game.Players:GetPlayers()) do c = v.CharacterAdded:wait() v.Character.Humanoid.Health = 0 end end
Those didn't effect all players though, it only effected 1 player at random, for both. This is just a cutout of my script, but please help with
Simple, let's say you want to damage every player in the game by half their health. You could say this:
for i, v in pairs(game.Players:GetChildren()) do -- i is what player the for loop is currently on, the v is the payer itself. --Here in the loop, you can say whatever you want to happen to everybody. v.Character.Humanoid.Health = 50 end
You need to create a clone of the knife and give the clone to each player, otherwise the knife will not be in ServerStorage for the next iteration over the players:
game.ServerStorage.Knife:Clone().Parent = v:WaitForChild("Backpack")
You are also waiting for 60 seconds for each player before then killing each player. It is unusual that you are iterating over the players inside a loop that is iterating over all the players. I can't tell what your intentions are there. If you tell me what you want it to do, I might be able to help further.