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

How to fix tool pick up script from partparent?

So ive been trying to make a brick that once clicked gives you an object. I have the script set up to go from the Lighting but i want the tool itself to be a Child of the ParentPart and still give it to you.

function hi(x)
	local y = x.Backpack
	local z = game.Lighting["Gun"] 
	z:Clone().Parent = y
end

script.Parent.ClickDetector.MouseClick:connect

Please help Anons

1 comment

0

I'm assuming by ParentPart you mean the part that is getting clicked?

2 answers

✓ Accepted answer

All you need to to is move "Gun" from lighting into the part and this script will work.

Also another tip don't use lowercase connect since roblox have deprecated it.

function hi(x)
	 local z = script.Parent.Gun
	z:Clone().Parent = x.Backpack
end

script.Parent.ClickDetector.MouseClick:Connect(hi)

11 comments

0

I also need a click detector correct? (Im more of a builder)

0

Yes you also need a insert a click detector into the part.

0

I have it set up like this in the work space: Workspace>Part>ClickDetector>Script>Gun. But then i go to test the game and the part doesnt give me my gun. Ik im doing something wrong but what?

0

Put the ClickDetector Script and Gun into the Part, don't put them inside of eachother.

0
0

oof its still not working. Setup: Workspace>Part>Click Detector> Script, Gun (The gun is in the part and not the script) But it still doesnt work. Sorry for spamming your notifications over this but i really need to figure this out.

0

Its fine i get spammed alot. Just put them in the order that i sent in the image (http://prntscr.com/mmvvzh)

0

Ya Yeet! Thanks for the help. As i said before: Im more of a builder and less of a scripter. But anyways thank for the help!

0

No problem :D

0

I would upvote the answer but dont have the rep lol. Anyways have a great day!

0

:Clone().Parent = Deprecated. Use local Clone = z:Clone() Clone.Parent = x.Backpack

You need to add "(function()" after connect.

Example:

script.Parent.ClickDetector.MouseClick:connect(function()

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