Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to fix tool pick up script from partparent?

Asked by 5 years ago

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

0
I'm assuming by ParentPart you mean the part that is getting clicked? checkerscat2 116 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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)
0
I also need a click detector correct? (Im more of a builder) iNykoda 3 — 5y
0
Yes you also need a insert a click detector into the part. sonysunny 36 — 5y
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? iNykoda 3 — 5y
0
Put the ClickDetector Script and Gun into the Part, don't put them inside of eachother. sonysunny 36 — 5y
View all comments (7 more)
0
http://prntscr.com/mmvvzh like that. sonysunny 36 — 5y
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. iNykoda 3 — 5y
0
Its fine i get spammed alot. Just put them in the order that i sent in the image (http://prntscr.com/mmvvzh) sonysunny 36 — 5y
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! iNykoda 3 — 5y
0
No problem :D sonysunny 36 — 5y
0
I would upvote the answer but dont have the rep lol. Anyways have a great day! iNykoda 3 — 5y
0
:Clone().Parent = Deprecated. Use local Clone = z:Clone() Clone.Parent = x.Backpack namespace25 594 — 5y
Ad
Log in to vote
0
Answered by
Clorize 31
5 years ago

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

Example:

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

Answer this question