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

Character Meshes won't disapear/destroy?

This is in ServerScriptService, I am trying to make it take of all meshes (turn into normal mesh)

--Removes Character Meshes
game.Players.PlayerAdded:connect(function(plr)
  plr.CharacterAdded:connect(function(char)
  local Children=char:GetChildren()
  repeat wait()
   local Found=false
   for _,Child in pairs(Children) do
    if Child:IsA("CharacterMesh") then
     Child:Destroy()
     Found=true
    end
   end
  until Found==true
 end)
end)

1 answer

✓ Accepted answer

Problem

I'm not exactly seeing a problem with your script, it should be looping through all the objects in the character. The only thing I would suggest is you using the ChildAdded event on the character model. For one thing, it's cleaner, and another, it will detect any objects entering the character model.


Solution

game.Players.PlayerAdded:connect(function(Player) --Player Enters, connect to them.
    Player.CharacterAdded:connect(function(Character) --That Player has a new Character, connect to it.
	    Character.ChildAdded:connect(function(Object) --There is something new added to the Character, the script will need to check it out.
		    if Object:IsA('CharacterMesh') then --The new object is a CharacterMesh, the script should do something to it.
			    Object:Destroy() --Destroy it, it will get deleted.
			    print('Found and Deleted Character Mesh.')
		    end
		end)
	end)
end)

######Remember, if this answer helped, do not forget to upvote. If I solved your problem do not forget to hit that Accept Answer button to the right.

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