Wolves25
|
  |
| Joined: 24 Feb 2009 |
| Total Posts: 208 |
|
|
| 15 Oct 2013 07:52 PM |
So this script is supposed to remove the players hat, shirt, and pants as well as set their arms, legs, torso, and head a gray color. For some reason it's not working in online mode or in a test server. Help?
--Remove Player Hat, Shirt, Pants. Set Player Colours. game.Players.PlayerAdded:connect(function(player) playerName = player.Name hat = Workspace[playerName]:FindFirstChild("Hat") shirt = Workspace[playerName]:FindFirstChild("Shirt") pants = Workspace[playerName]:FindFirstChild("Pants") if hat ~= nil then hat:Remove() end if shirt ~= nill then shirt:Remove() end if pants ~= nil then pants:Remove() end Workspace[playerName].Head.Color = BrickColor.new("Mid gray") Workspace[playerName].LeftArm.Color = BrickColor.new("Medium stone grey") Workspace[playerName].RightArm.Color = BrickColor.new("Medium stone grey") Workspace[playerName].LeftLeg.Color = BrickColor.new("Black") Workspace[playerName].RightLeg.Color = BrickColor.new("Black") Workspace[playerName].Torso.Color = BrickColor.new("Medium stone grey") end) |
|
|
| Report Abuse |
|
|
GGGGG14
|
  |
| Joined: 29 Jan 2012 |
| Total Posts: 25344 |
|
|
| 15 Oct 2013 07:55 PM |
Several problems...
First of all, a Player is the child of the Players part of the game, not the workspace, so the beginning and end need to be changed. Also you need some conditional statements to flow your script.
It doesn't flow. |
|
|
| Report Abuse |
|
|
Wolves25
|
  |
| Joined: 24 Feb 2009 |
| Total Posts: 208 |
|
|
| 15 Oct 2013 07:57 PM |
That's why I used this
playerName = player.Name
Using that I got the player name which should allow access to the player model in the workspace. Am I right? |
|
|
| Report Abuse |
|
|
GGGGG14
|
  |
| Joined: 29 Jan 2012 |
| Total Posts: 25344 |
|
|
| 15 Oct 2013 08:01 PM |
game.Players.PlayerAdded:connect(function(player) --that puts "player" under the Players Category
playerName = player.Name -- that would be the Name of the "player", but player is not in the workspace
A player isn't a model in the workspace though. |
|
|
| Report Abuse |
|
|
MHebes
|
  |
| Joined: 04 Jan 2013 |
| Total Posts: 2278 |
|
|
| 15 Oct 2013 08:02 PM |
Try this, haven't tested it though:
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) for _,child in pairs(character:GetChildren()) do if child:IsA("Hat") or child:IsA("Pants") or child:IsA("Shirt") then child:Destroy() elseif child:IsA("BasePart") then if child.Name:find("Arm") or child.Name == "Torso" then child.BrickColor = BrickColor.new("Medium stone grey") elseif child.Name:find("Leg") then child.BrickColor = BrickColor.new("Black") elseif child.Name == "Head" then child.BrickColor = BrickColor.new("Mid gray") end end end end) end) |
|
|
| Report Abuse |
|
|
Wolves25
|
  |
| Joined: 24 Feb 2009 |
| Total Posts: 208 |
|
|
| 15 Oct 2013 08:04 PM |
| I know what you're saying but the physical character is stored in the Workspace. Where the health scripts, animation scripts, sounds, and physical parts of the character are stored. By using playerName = player.Name I am using the string playerName to get to the physical model of the character. I think there is a simpler way to do this however. |
|
|
| Report Abuse |
|
|
GGGGG14
|
  |
| Joined: 29 Jan 2012 |
| Total Posts: 25344 |
|
|
| 15 Oct 2013 08:05 PM |
@Wolves ehh just use the other guys script.
:P |
|
|
| Report Abuse |
|
|
Wolves25
|
  |
| Joined: 24 Feb 2009 |
| Total Posts: 208 |
|
|
| 15 Oct 2013 08:16 PM |
| His works in a test server but not in online mode. Hmmmm.... |
|
|
| Report Abuse |
|
|
MHebes
|
  |
| Joined: 04 Jan 2013 |
| Total Posts: 2278 |
|
|
| 15 Oct 2013 08:18 PM |
Humph. I would've thought it the other way around, honestly. Try starting it online and reseting your character to see if that works. Could be the character is loading too fast or something... |
|
|
| Report Abuse |
|
|
Wolves25
|
  |
| Joined: 24 Feb 2009 |
| Total Posts: 208 |
|
|
| 15 Oct 2013 08:20 PM |
| Still didn't work. And I honestly can't think of any reason why it wouldn't work properly! |
|
|
| Report Abuse |
|
|
MHebes
|
  |
| Joined: 04 Jan 2013 |
| Total Posts: 2278 |
|
|
| 15 Oct 2013 08:26 PM |
I can't either.... Try adding a player:LoadCharacter() after the CharacterAdded function, but before the PlayerAdded function ends. |
|
|
| Report Abuse |
|
|