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

How to make players wear clothes if they click on a GUI button?

I'm trying to make a catalog which allows players to change their clothing. Here's what I've came up with so far, any suggestions on how to make it work?

P.s I haven't been trying to script for long so expect noob mistakes lol

local player = game.Players.LocalPlayer
local shirt = game.ServerStorage:findFirstChild("Shirt")
local pants = game.ServerStorage:findFirstChild("Pants")
debounce = true

function Click()
local clothing = player.Character:GetChildren()

if clothing.className == "Pants" or clothing.className == "Shirt"  then
clothing:destroy()

shirt:Clone().Parent = player.Character
pants:Clone().Parent = player.Character

end
end

script.Parent.MouseButton1Down:connect(Click)

2 answers

✓ Accepted answer

Here, you should be able to edit the clothes and where you click it. It is a local script so it works with filteringEnabled!

script.Parent.MouseButton1Down:connect(function()
local playername = game.Players.LocalPlayer.Name
local player = workspace:FindFirstChild(""..playername.."")
if player ~= nil then
  player:FindFirstChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=0000000" 
  player:FindFirstChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=0000000"
end
end)

2 comments

0

Perfect! Thank you so much

0

You should use game.Players.LocalPlayer.Character instead of finding the character by name.

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