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

I'm trying to make an apple pickup. No errors, but it doesn't seem to work. Any help?

Asked by
ZenTGE 4
6 years ago
local apple = script.Parent
local CD = apple.ClickDetector

CD.MouseClick:connect(function(player)
    local BP = player.Backpack
    if BP:FindFirstChild('apple') == false then
        apple.Parent:Clone().Parent = BP

    end
end)

I have a ClickDetector, and a handle. Not sure where I'm going wrong.

0
What dose apple.Parent mean? Apple should be in a tool with a handle., If you can, show a link to a photo of your setup for the apple in workspace or where ever it is located. Thank you. JellyYn 70 — 6y

3 answers

Log in to vote
0
Answered by
GingeyLol 338 Moderation Voter
6 years ago
Edited 6 years ago
local apple = script.Parent
local CD = apple.ClickDetector

CD.MouseClick:Connect(function(player) --use :Connect
    local BP = player.Backpack
    if BP:FindFirstChild('apple') == nil then --nil not false
        apple.Parent:Clone().Parent = BP
    end
end)
0
Thanks so much! ZenTGE 4 — 6y
Ad
Log in to vote
-1
Answered by 6 years ago
Edited 6 years ago

Rename apple to Handle and the tool to apple

0
I edited Prbo1201 56 — 6y
0
Did it work? Prbo1201 56 — 6y
0
Sadly not. ZenTGE 4 — 6y
0
Try adding a debounce Prbo1201 56 — 6y
Log in to vote
-1
Answered by 6 years ago
Edited 6 years ago
1   local apple = script.Parent
2   local CD = apple.ClickDetector
3    
4   CD.MouseClick:Connect(function(player) 
5       local BP = player.Backpack
6       if BP:FindFirstChild('apple') ~= nil then 
        --if apple isn't nil the next line will run.
7           apple.Parent:Clone().Parent = BP
8       end
9   end)
0
Gingey has the script saying if apple IS nil creatorstorm 8 — 6y
0
Please accept this as the answer if it fixes your issue. creatorstorm 8 — 6y

Answer this question