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

Why does this button not work? It is supposed to give the player certain clothing.

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

0

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.

1 answer

Try Putting The script.Parent.MouseButton1Click:connect(onClick) On The Top Of The Code.

1 comment

0

Instead Of This: function onClick(hit)

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