This code is supposed to change the players pants and shirt
function onTouch(r) -- when the brick is touched wait(1) -- waits one second local p = r.Parent:WaitForChild("Pants") -- finds the pants from the player who touched it local s = r.Parent:WaitForChild("Shirt") --finds the shirt if (p ~= nil) then -- checks if it exists p.PantsTemplate = "rbxassetid://146138748" -- changes the pants s.ShirtTemplate = "rbxassetid://145609726" -- changes the shirt end -- ends end -- ends script.Parent.Touched:connect(onTouch) -- connects
It seems that you should check for a humanoid and make the script more efficient. If there was a part that touched the block that wasn't a part of a player, your code would have brought up an error.
script.Parent.Touched:connect(function(hit) local hum = hit.Parent:FindFirstChild("Humanoid") if hum then wait(0.5) local pants = hit.Parent:FindFirstChild("Pants") if pants then pants.PantsTemplate = "rbxassetid://146138748" end local shirt = hit.Parent:FindFirstChild("Shirt") if shirt then shirt.ShirtTemplate = "rbxassetid://145609726" end end end)
I hope you understand!
Don't forget to accept this as the answer!