generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Simple script... No clue what or where the problem is.

Previous Thread :: Next Thread 
bellyboy99 is not online. bellyboy99
Joined: 27 Jan 2010
Total Posts: 433
08 Sep 2013 01:12 PM
It works when someone dies in build mode, but not when they join. It also doesn't work at all online.


function onAdded(character)
wait()
find = character:FindFirstChild("Torso")
if find ~= nil then
meshs = character:GetChildren()
for i = 1,#meshs do
if meshs[i].ClassName == "CharacterMesh" or meshs[i].ClassName == "Hat" or meshs[i].ClassName == "ShirtGraphic" or meshs[i].ClassName == "Shirt" or meshs[i].ClassName == "Pants" then
meshs[i]:Remove()
end
end
tshirt = find:FindFirstChild("roblox")
if tshirt ~= nil then
tshirt:Remove()
end
end
end

game.Players.PlayerAdded:connect(function(player)
print(player.Character)
player.CharacterAdded:wait()
onAdded(player.Character)
end)"

game.Workspace.ChildAdded:connect(onAdded,character)
Report Abuse
bellyboy99 is not online. bellyboy99
Joined: 27 Jan 2010
Total Posts: 433
08 Sep 2013 01:14 PM
It's obviously a connection problem. I guess I don't know how to wait for the character? I don't know..
Report Abuse
DrProx is not online. DrProx
Joined: 18 Nov 2009
Total Posts: 1138
08 Sep 2013 01:19 PM
function onAdded(character)
wait(3) -- sometimes assets take a bit to load up
for _,v in pairs(character:GetChildren()) do
if v:IsA("CharacterMesh") or v:IsA("Hat") or v:IsA("Shirt") or v:IsA("Pants") or v:IsA("ShirtGraphic") do
v:Destroy()
end
end
tee = character:FindFirstChild("roblox", true) -- recursive search
if tee then
tee:Destroy()
end
end

game.Players.PlayerAdded:connect(function(p)
repeat wait() until p.Character
onAdded(p)
p.CharacterAdded:connect(function(c)
onAdded(c)
end)
end)
Report Abuse
bellyboy99 is not online. bellyboy99
Joined: 27 Jan 2010
Total Posts: 433
08 Sep 2013 01:23 PM
Thank you. That helped in many ways!
Report Abuse
bellyboy99 is not online. bellyboy99
Joined: 27 Jan 2010
Total Posts: 433
08 Sep 2013 01:27 PM
It still doesn't work the first time. Although I learned a few things from it.
Report Abuse
DrProx is not online. DrProx
Joined: 18 Nov 2009
Total Posts: 1138
08 Sep 2013 01:29 PM
Oops, made a small typo:

function onAdded(character)
wait(3) -- sometimes assets take a bit to load up
for _,v in pairs(character:GetChildren()) do
if v:IsA("CharacterMesh") or v:IsA("Hat") or v:IsA("Shirt") or v:IsA("Pants") or v:IsA("ShirtGraphic") do
v:Destroy()
end
end
tee = character:FindFirstChild("roblox", true) -- recursive search
if tee then
tee:Destroy()
end
end

game.Players.PlayerAdded:connect(function(p)
repeat wait() until p.Character
onAdded(p.Character)
p.CharacterAdded:connect(function(c)
onAdded(c)
end)
end)
Report Abuse
bellyboy99 is not online. bellyboy99
Joined: 27 Jan 2010
Total Posts: 433
08 Sep 2013 01:35 PM
you should also replace 'do' with 'then'.
Report Abuse
DrProx is not online. DrProx
Joined: 18 Nov 2009
Total Posts: 1138
08 Sep 2013 01:36 PM
Oops, didn't notice that. I'm scripting my own project as I patrol SH so I'm going a bit rushed. :P
Report Abuse
bellyboy99 is not online. bellyboy99
Joined: 27 Jan 2010
Total Posts: 433
08 Sep 2013 01:38 PM
Well thank you for your time sir. It works amazingly! If you need anything, I owe you one. Aha
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image