Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I make a button where if you click it, you change shirt?

I want to make a disguise system where if you click something, your shirt id is replaced with the one in the script therefore disguising you. Please could someone provide a script that does that?

When the NPC is dead, they will be ragdolled and you can click the upper torso. What should happen is your character's shirt id will be replaced by the NPC's shirt id (and pants) therefore disguising you. I will also add a line that disables the trespassing value (this is located in Player scripts).

I've had a go by using this code:

local humanoid = --I have no idea how to get character from click detector

function Click()
 --"http://www.roblox.com/asset/?id=1972067" Shirt
 --"http://www.roblox.com/asset/?id=1960214" Pants	
local description = humanoid:GetAppliedDescription()
description.Shirt = "http://www.roblox.com/asset/?id=1972067"
humanoid:ApplyDescription(description)
end


script.Parent.ClickDetector.MouseClick:Connect(Click)

Any help is appreciated.

1 comment

0

I updated my post

1 answer

✓ Accepted answer

You should lookup HumanoidDescription, it allows you to change the appearance of your character. https://developer.roblox.com/en-us/articles/humanoiddescription-system

Basic example:

local description = humanoid:GetAppliedDescription()
description.Shirt = your new id
humanoid:ApplyDescription(description)

Edit: Alright so the MouseClick event passes the player who clicked on the clickdetector, that means you can do > function Click(otherPlayer)

From there you just get the character from the other player, and from there you can get the humanoid of that character.

Full code is something like this:

function Click(otherPlayer)
	local character = otherPlayer.Character
	if character == nil then return end -- make sure the character is set
	
	local humanoid = character:WaitForChild("Humanoid")

5 comments

0

How do I define the humanoid of the player who clicked the upper torso of the ragdoll? That article is too complicated

0

You should add some code if you want help with that. You have explained nothing for that.

0

ok i will quickl edit my post

0

I have edited the post and added my code to it

0

Thank you very much! :)

This discussion is preserved as it was. New answers, comments, and votes are closed.