|
| 08 Sep 2014 07:01 PM |
I need to be able to have all the characters in the game spawn with a certain outfit, how would I do this?
Swag like Caillou. |
|
|
| Report Abuse |
|
|
| |
|
|
| 08 Sep 2014 07:14 PM |
You can monitor when a character spawns by using the CharacterAdded event. To keep track of THAT, though, you need a PlayerAdded event as well, to track when a player joins the game
game.Players.PlayerAdded:connect(function(Player) -- normally, this will only fire once per player Player.CharacterAdded:connect(function(Character) -- this will fire every time a player's character respawns -- CODE HERE end) end)
Assuming your uniform is pretty basic (just shirt & pants), the next thing you need to do is see if the character is already wearing clothing. If he is, it's as simple as changing the ID of both. Otherwise, you need to create clothing and add them to the character.
game.Players.PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(Character) local shirt = Character:FindFirstChild("Shirt") local pants = Character:FindFirstChild("Pants") if shirt then shirt.ID = -- ID OF YOUR UNIFORM'S SHIRT else shirt = Instance.new("Shirt") shirt.Parent = Character shirt.ID = -- ID OF YOUR SHIRT end if pants then pants.ID = -- ID OF YOUR UNIFORM'S PANTS else pants = Instance.new("Pants") pants.Parent = Character pants.ID = -- ID OF YOUR PANTS end end) end) |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2014 07:30 PM |
@TheCrook, would this be a localscript?
Swag like Caillou. |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2014 07:33 PM |
| Nah, a regular script should work. BTW, the code I wrote is meant to be an example, not so much a working product. I was hoping to explain how the idea would work instead of just giving it away xD |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2014 07:35 PM |
I completely suck at scripting, so ggnore. Swag like Caillou. |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2014 07:37 PM |
It doesn't work, qq.
ehh
Swag like Caillou. |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2014 07:40 PM |
| I put my IDs where they needed to go, inside a script, reset and nothing. |
|
|
| Report Abuse |
|
|
7LC
|
  |
| Joined: 07 Sep 2014 |
| Total Posts: 45 |
|
|
| 08 Sep 2014 07:44 PM |
| Want them to automatically char? Tell me what you want, you have to have a roblox alt with the outfit you want and in the game add hair modules. |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2014 07:45 PM |
I gotta go, so I'll introduce you to some wiki links that might give you an idea of how to do what you need. Some of these pages are a bit lengthy, but necessary if you'd like to rely less on the scripting helper's forum (which doesn't always deliver).
The basics of scripting: http://wiki.roblox.com/index.php?title=Absolute_beginner%27s_guide_to_scripting
The PlayerAdded event: http://wiki.roblox.com/index.php?title=PlayerAdded_(Event)
The CharacterAdded event: http://wiki.roblox.com/index.php?title=CharacterAdded_(Event)
The wiki is a GREAT tool. I always make sure to keep it in an open tab in case there's something I'd like to learn more about. |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2014 07:46 PM |
What I want to do is apon joining the server, or even respawning I want the character to spawn or respawn with a certain outfit. But I want them to keep their hats.
http://www.roblox.com/Hospital-Gown-item?id=157420445
http://www.roblox.com/Hospital-Gown-item?id=143886834
Swag like Caillou. |
|
|
| Report Abuse |
|
|
DevFrank
|
  |
| Joined: 04 Apr 2012 |
| Total Posts: 1469 |
|
|
| 08 Sep 2014 07:47 PM |
I made this script awhile ago, hope this helps!
DefaultPants = "0" --Pants ID Here don't forget to -1 DefaultShirt = "0" --Shirt ID Here don't forget to -1
game.Players.PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(character) repeat wait() until character c_ = game.Workspace:FindFirstChild(Player.Name) local Shirt = c_:FindFirstChild("Shirt") local Pants = c_:FindFirstChild("Pants") if Shirt ~= nil then Shirt:Destroy() end if Pants ~= nil then Pants:Destroy() end -- Shirt = Instance.new("Shirt", c_) Shirt.Name = "Shirt" Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="..DefaultShirt -- Pants = Instance.new("Pants", c_) Pants.Name = "Pants" Pants.PantsTemplate = "http://www.roblox.com/asset/?id="..DefaultPants -- end) end) |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2014 07:51 PM |
DefaultPants = "157420445" --Pants ID Here don't forget to -1 DefaultShirt = "143886834" --Shirt ID Here don't forget to -1
game.Players.PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(character) repeat wait() until character c_ = game.Workspace:FindFirstChild(Player.Name) local Shirt = c_:FindFirstChild("Shirt") local Pants = c_:FindFirstChild("Pants") if Shirt ~= nil then Shirt:Destroy() end if Pants ~= nil then Pants:Destroy() end -- Shirt = Instance.new("Shirt", c_) Shirt.Name = "Shirt" Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="..DefaultShirt -- Pants = Instance.new("Pants", c_) Pants.Name = "Pants" Pants.PantsTemplate = "http://www.roblox.com/asset/?id="..DefaultPants -- end) end)
This didn't work. |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2014 07:53 PM |
game.Players.PlayerAdded:connect(function(lawl) lawl.CharacterAdded:connect(function(char) for I,v in pairs(char:GetChidren()) do if v.ClassName == "Pants" or v.ClassName == "Shirt" then v:Destroy() end end Shirt = Instance.new("Shirt") Shirt.ShirtTemplate = "" Pants = Instance.new("Pants") Pants.PantsTemplate = "" Shirt.Parent = char Pants.Parent = char end) end) |
|
|
| Report Abuse |
|
|
| |
|
|
| 08 Sep 2014 07:57 PM |
Did you try it...
lol...
And if you did, did it work or not? |
|
|
| Report Abuse |
|
|
DevFrank
|
  |
| Joined: 04 Apr 2012 |
| Total Posts: 1469 |
|
|
| 08 Sep 2014 07:57 PM |
I noticed you didn't -1 from the ID. This works, you just don't know how to apply shirt templates.. Normal Script btw
DefaultPants = "157420444" --Pants ID Here don't forget to -1 DefaultShirt = "143886833" --Shirt ID Here don't forget to -1
game.Players.PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(character) repeat wait() until character c_ = game.Workspace:FindFirstChild(Player.Name) local Shirt = c_:FindFirstChild("Shirt") local Pants = c_:FindFirstChild("Pants") if Shirt ~= nil then Shirt:Destroy() end if Pants ~= nil then Pants:Destroy() end -- Shirt = Instance.new("Shirt", c_) Shirt.Name = "Shirt" Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="..DefaultShirt -- Pants = Instance.new("Pants", c_) Pants.Name = "Pants" Pants.PantsTemplate = "http://www.roblox.com/asset/?id="..DefaultPants -- end) end) |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2014 07:58 PM |
Tried it, didn't work. I'm in test mode trying the script. I put the script in: game.Players.PlayerAdded:connect(function(lawl) lawl.CharacterAdded:connect(function(char) for I,v in pairs(char:GetChidren()) do if v.ClassName == "Pants" or v.ClassName == "Shirt" then v:Destroy() end end Shirt = Instance.new("Shirt") Shirt.ShirtTemplate = "143886833" Pants = Instance.new("Pants") Pants.PantsTemplate = "157420444" Shirt.Parent = char Pants.Parent = char end) end)
then reset and nothing Swag like Caillou. |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2014 07:59 PM |
game.Players.PlayerAdded:connect(function(lawl) lawl.CharacterAdded:connect(function(char) wait(2) for I,v in pairs(char:GetChidren()) do if v.ClassName == "Pants" or v.ClassName == "Shirt" then v:Destroy() end end Shirt = Instance.new("Shirt") Shirt.ShirtTemplate = "" Pants = Instance.new("Pants") Pants.PantsTemplate = "" Shirt.Parent = char Pants.Parent = char end) end)
-- Try this instead
|
|
|
| Report Abuse |
|
|
DevFrank
|
  |
| Joined: 04 Apr 2012 |
| Total Posts: 1469 |
|
|
| 08 Sep 2014 08:09 PM |
To clear everything up, mine does indeed work.
http://www.roblox.com/Custom-Player-Clothes-Demo-place?id=177026433
@Jake, I'm not going to bother fixing that script. One thing is that you have "Chidren" instead of "Children" |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2014 08:15 PM |
For your test game I even copied the script into my game and it didn't work, is it because I am in Solo test mode? or something?
Swag like Caillou. |
|
|
| Report Abuse |
|
|
DevFrank
|
  |
| Joined: 04 Apr 2012 |
| Total Posts: 1469 |
|
|
| 08 Sep 2014 08:17 PM |
| Where are you putting the script in your game? |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2014 08:19 PM |
I have the script in my workspace, its just a regular script with the code inside of it.
Swag like Caillou. |
|
|
| Report Abuse |
|
|
DevFrank
|
  |
| Joined: 04 Apr 2012 |
| Total Posts: 1469 |
|
|
| 08 Sep 2014 08:22 PM |
| Is it published to roblox? I just want to see if it really doesnt work. (at your place) |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2014 08:23 PM |
game.Players.PlayerAdded:connect(function(lawl) lawl.CharacterAdded:connect(function(char) wait(2) for I,v in pairs(char:GetChildren()) do if v.ClassName == "Pants" or v.ClassName == "Shirt" then v:Destroy() end end Shirt = Instance.new("Shirt") Shirt.ShirtTemplate = "" Pants = Instance.new("Pants") Pants.PantsTemplate = "" Shirt.Parent = char Pants.Parent = char end) end)
NOOOOOW should work.
|
|
|
| Report Abuse |
|
|