Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My script won't work?

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

✓ Accepted answer

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.

2 comments

0

Helped alot, thanks.

0

No problem.

(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

This discussion is preserved as it was. New answers, comments, and votes are closed.