There is a button I can click, that is supposed to make the player wear certain clothing when they click the button.
Here is what I have:
function onClick(hit)
local h = hit.Parent:findFirstChild("Humanoid")
if h~=nil then
local s = onClick().Parent:findFirstChild("Pants")
if s~=nil and d~=nil then
hit.Parent.Pants:remove()
script.Parent.Pants:clone().Parent = hit.Parent
elseif s~=nil then
hit.Parent.Pants:remove()
script.Parent.Pants:clone().Parent = hit.Parent
elseif d~=nil then
script.Parent.Pants:clone().Parent = hit.Parent
elseif s==nil and d==nil then
script.Parent.Pants:clone().Parent = hit.Parent
end
end
end
script.Parent.MouseButton1Click:connect(onClick)

1 comment
You never defined "d", and at line 4, onClick() is not an object, but a function, therefore you cannot find the parent of it. Edit//Also, MouseButton1Click doesn't give a hit to connect your function on.