This might be a silly question for many people. However, I am not good at scripting and I am currently learning that! So pls forgive me to ask this silly question
Expected result: Get all the players and kill them one by one
My issue now: I watched a few youtube tutorials to achieve this but they didn’t work. And i tried to code it myself and the players didn’t get killed and there are no errors in the output!
local players = game:GetService("Players")
local player = players:GetPlayers()
task.wait(90)
for _, player in ipairs(player) do
local hu = player:WaitForChild("Humanoid")
hu.Health = 0
end
Can someone tell me what’s wrong with this code? (btw my english is bad pls forgive me if there is a lot of grammatical mistakes)
local players = game:GetService("Players")
local player = players:GetChildren()
task.wait(90)
for _, player in ipairs(player) do
local hu = player.Character:WaitForChild("Humanoid")
hu.Health = 0
end
local players = game:GetService("Players")
task.wait(90)
for _, v in ipairs(players:GetChildren()) do
local hu = v.Character:WaitForChild("Humanoid")
hu.Health = 0
end
The value for the table and singual player were the same, so you were waiting for the humanoid in the player table. And you waited for the humanoid in the player instance and not the character.