game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(message)
message=message:lower()
if message:sub(1,10)==prefix.."loopkill"..prefix2 and list[player.Name] then
local scparent=findplayer(message:sub(11))
if scparent and scparent.Character then
local ns=script.Script:clone()
ns.Code.Value=[[
local player=game.Players:GetPlayers()
while true do
wait()
player.Character.Humanoid.Health=0
end]]
ns.Name="NewScr"
ns.Parent=game.Workspace
end end end)end)
--There are no error messages.
✓ ANSWER ACCEPTED
An error in a command to start a loopkill, using an external stringvalue?
1 answer
✓ Accepted answer
The problem is in your code value. The GetPlayers method of Players service returns a table, not a single player. Therefore, you have to index those players and do what you want with them.
ns.Code.Value=[[
local players=game.Players:GetPlayers()
while true do
wait()
for _, player in pairs(players) do
player.Character.Humanoid.Health=0
end
end
]]
I am not sure what you are trying to accomplish, but if this is not it, leave a comment.
Hope this helped.
1 comment
0
Thank you so much.
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Sorry, I'm new here.
I can see an error in your new script's string. 'GetPlayers' method returns a table, not a single object. That means you have to make a loop.
Could you possibly fix it for me?