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

Character Meshes won't disapear/destroy?

Asked by
FiredDusk 1466 Moderation Voter
9 years ago

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

Log in to vote
0
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
9 years ago

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.
Ad

Answer this question