Removing Given Clothes

I had this brainwave of an idea for my game. Basically its a railway game but this idea was you can choose what you want to be. Driver, Dispatcher, Guard or just a normal player. The Driver, Dispatcher and Guard would get given their respective uniforms, as shown below.

So there I am, programming along making this work. Now its time to script the “Delete my role”. This is where I froze.

How do I make it so that the clothes given are removed and the user gets their own clothes back?

Here’s my regular outfit. I need to workout a way to give back their original clothes and remove the given outfits. Anyone have any ideas? I’ve searched through this forum and scriptinghelpers and I cannot find anything.

Thanks.

5 Likes

Have you tried to use HumanoidDescriptions? You could get a humanoid description from the player and then apply it. Giving the clothing back!

3 Likes

There is actually a fairly simple way of doing this; though it has a few variations on it’s execution.

I’d personally recommend just using 2 string values to store the shirt and pants ids of the players whenever they change outfits, this way you can easily reset them; you could also just store them when the player joins and not set them afterwards.

Something such as:

-- outfit activation here
ShirtID = character.Shirt.ShirtTemplate
PantsID = character.Pants.PantsTemplate
-- Continue setting outfit
-- return activation
character.Shirt.ShirtTemplate = ShirtID
character.Pants.PantsTemplate = PantsID

Hope this helps.

3 Likes

ShirtID = character.Shirt.ShirtTemplate
PantsID = character.Pants.PantsTemplate

Don’t you need something on the end of this?

1 Like

I actually find this confusing to use. It has to fit into a RemoteEvent script (on the server side) and I’m finding it difficult because of where to exactly put them.

No, “ShirtTemplate” and “PantsTemplate” would be similar to saying “StringValue.Value”

1 Like

Because of where I put it, every time the remoteevent is fired for the user the shirt and pants template would be the ones they are wearing, not the original ones. How can I bypass this?

You could save their original shirt and pants template when they first join and whenever they reset, this would bypass that issue.

And how does one unintelligent person do this?

1 Like
-- local script inside of starterpack/startergui (wherever you keep the local script for remote events)
game.Players.CharacterAdded:Connect(function(char)
   if char then
      shirtid = game.Players.LocalPlayer.Character.Shirt.ShirtTemplate
      pantsid = game.Players.LocalPlayer.Character.Pants.PantsTemplate
   end
1 Like

The RemoteEvent script is a Server Script and is located inside ServerScriptService…

Hello, I know this sounds stupid but what about you just run
Player:LoadCharacter()

Ah, I must’ve been mistaken and assumed you were using :FireServer() as opposed to :FireClient, my mistake. I don’t see why you’d use a serverscript to change the shirt/pants id of a player as any changes made locally to the player are actually viewable to all.

Also a quick note: “game.Players.CharacterAdded” should be “game.Players.LocalPlayer.CharacterAdded”

You could just carry out everything in a local script, at least that’d be the easiest way in my opinion.

It’s not that, I have to give an Overhead GUI to the player’s head as well as give them some tools which I’ve already programmed.

Wait so if you change clothing from a client… does it actually replicate to the server? I dont think so

Unless it was patched recently (which I don’t believe it was since as far as I am aware it was an intentional feature), any changes made from the client towards that players avatar will replicate to the server. That’s why things like TP exploits work.

A solution of player:LoadCharacter() did work, although it respawns the player but I guess this could be a temporary solution.

I was actually not aware of this feature

I assumed you had team spawns put in place but you could log the player’s cloth ids ONCE he/she enters the game. Then you can use them in deleting the roles

Pretty sure I included game.Players.LocalPlayer.CharacterAdded as a method that would leave you with no reason to use LoadCharacter() or a server script at all. You don’t need to over complicate things; just use a local script and the method I provided which should work quite flawlessly.