I’m going to be very blunt. I know diddly nor squat about coding, and I have zero clue why this code would or would not work. Or any code for that matter.
What I want: To click a button and it applies 4 accessories, and changes the shirt and pants. I have a working click-to-change-clothes script, but I don’t know if I can just throw the accessory script on top of it or if the code has to be in one script? Right now the scripts are in separate blocks for testing purposes but i will eventually want them all in one.
What happens: I click the block and nothing happens
Here’s my Frankensteined attempt to code a click-to-give-accessories
script.Parent.ClickDetector.MouseClick:Connect(function(player)
local hatClone = game.ReplicatedStorage.Hat:Hat()
hatClone.Parent = game.Workspace:FindFirstChild(player.Name)
local shoulderClone = game.ReplicatedStorage.Shoulder:Shoulder1()
shoulderClone.Parent = game.Workspace:FindFirstChild(player.Name)
local shoulderClone = game.ReplicatedStorage.Shoulder:Shoulder2()
shoulderClone.Parent = game.Workspace:FindFirstChild(player.Name)
local frontClone = game.ReplicatedStorage.Front:Front()
frontClone.Parent = game.Workspace:FindFirstChild(player.Name)
end)
There is most likely a much easier way to make this code, I honestly thought as long as I have the shirt/accessory IDs it would just be as simple as putting them into the code : |
Note I do not want to make a morph with the shirt and accessories, I just want the items applied to the player’s character, and if that means the clothes don’t apply (if they have rthro) or their current accessories stick through the ones I apply, so be it.
Also, if needed, here’s the click-to-change-clothes script that DOES work
script.Parent.ClickDetector.MouseClick:Connect(function(Player)
local Shirt1 = script.Parent:WaitForChild("Shirt"):Clone()
local Pants1 = script.Parent:WaitForChild("Pants"):Clone()
if (Player) and (Player.Character) then
for _, Item in pairs(Player.Character:GetChildren()) do
if Item:IsA("Shirt") then
Item:Destroy()
Shirt1.Parent = Player.Character
elseif Item:IsA("Pants") then
Item:Destroy()
end
end
end
Shirt1.Parent = Player.Character
Pants1.Parent = Player.Character
end)
And here’s what’s in that part.
Do I need to combine these scripts or will adding two scripts to one part make it do both?
I apologize if I’m not giving enough information, I am extremely confused by all this and have been trying to make this work for a week.