Okay. So I'm writing a script that will create an SAO-like death; however, I am using a grey rather than a blue. So far, this is how it turned out. As you can see, the head is left, this is due to some testing as the script was being a bit crazy earlier.

local playerevent = game.ReplicatedStorage:WaitForChild('Events'):WaitForChild('PlayerDead') -- Grabs the event.
local emitter = game.ReplicatedStorage:WaitForChild('Resources'):WaitForChild('DeathEmitter') --Grabs the emitter.
local numberofparts = 0 --Used to add to number of parts.
playerevent.OnServerEvent:connect(function(player)
	local clone = emitter:Clone() 
	clone.Parent = player.Character.Torso
	for i, v in ipairs(player.Character:GetChildren()) do
		if v.ClassName == "Accessory" or v.ClassName == "Shirt" or v.ClassName == "Pants" or v.ClassName == 'BodyColors' then --No longer running, just the elseif
			v:Destroy()
			print(v.Name) 
		elseif v.ClassName == "Part" and  v.Name ~= "HumanoidRootPart" then
			v.Anchored = true --Nothing anchoring?
			print(v.Name) --Everything prints out.
			v.BrickColor = BrickColor.new('Dark stone grey')
			v.Material = "Neon"
			numberofparts = numberofparts + 1
--[[		if v:FindFirstChild('Mesh') then
				v.Mesh:Destroy()
			end
This if statement is a bit weird, because the main if statement will work, but the main elseif won't work if it's here ]]
			if numberofparts == 5 then
				wait(1)  --This works correctly. Everything gets destroyed.
				player.Character["Left Leg"]:Destroy()
				player.Character["Left Arm"]:Destroy()
				player.Character['Right Arm']:Destroy()
				player.Character['Right Leg']:Destroy()
				player.Character.Torso:Destroy()
				player.Chararacter.Head:Destroy()
				numberofparts = 0
			end
		elseif v.Name == "HumanoidRootPart" then
			v.Anchored = true
		end
	end
end)

I'm not getting any errors, and this is a Script in ServerScriptService. FilterEnabled is Enabled. If the code is hard to read due to my comments, hover over the script and click the paper with the less-than and greater-than sign on them, in the upper right corner.

2 comments

0

I don't understand the problem. What's not working in this script, exactly?

0

Look at the link in the word 'this'. One of the if statements isn't running, so it's not removing clothing.