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

My script won't work?

Asked by
phriol 25
9 years ago

Can someone please proofread my script because I tried it a lot of times and it didn't work. I tried proofreading but that didn't work...

limbs = {'Torso', 'Head', 'Right Arm', 'Left Arm', 'Right Leg', 'Left Leg'}

player = {"phriol"}

for _,v in pairs(player) do
    me = game.Players:FindFirstChild(v)
    if not me then return end
    mylimbs = me.Character:FindFirstChild(limbs)
    if not mylimbs then return end
    mylimbs:remove()
end

2 answers

Log in to vote
1
Answered by 9 years ago

The first part is right when trying to find the player in the table, but all you need is another for loop to go through each value in the limbs table.

Also, you want to use Destroy instead of remove as remove is deprecated and ROBLOX suggests you use Destroy.


Code:

limbs = {'Torso', 'Head', 'Right Arm', 'Left Arm', 'Right Leg', 'Left Leg'}

player = {"phriol"}

for _,v in pairs(player) do
    me = game.Players:FindFirstChild(v)
    if not me then return end
    for _,limb in pairs(limbs) do --Loop through each value of the table, _ is the index, limb is the value.
        mylimbs = me.Character:FindFirstChild(limb) --Check if the limb exists.
        if not mylimbs then return end
        mylimbs:Destroy()
    end
end

I hope my answer helped you. If it did, be sure to accept it.

0
Helped alot, thanks. phriol 25 — 9y
0
No problem. Spongocardo 1991 — 9y
Ad
Log in to vote
0
Answered by
Marios2 360 Moderation Voter
9 years ago

(There was something here, but then i realized you were not new.)

local players = game.Players:GetPlayers() --Function for getting players

for _,player in pairs(players) do
    player.Character:ClearChildren() --Remove all children of the parent.
end

Answer this question