Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

An error in a command to start a loopkill, using an external stringvalue?

Asked by 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
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.
0
Sorry, I'm new here. Huminoidjoe 20 — 8y
0
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. LetThereBeCode 360 — 8y
0
Could you possibly fix it for me? Huminoidjoe 20 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

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.

0
Thank you so much. Huminoidjoe 20 — 8y
Ad

Answer this question