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

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

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.

2 comments

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.

3 answers

✓ Accepted answer
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)

1 comment

0

Thanks so much!

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)

2 comments

0

Gingey has the script saying if apple IS nil

0

Please accept this as the answer if it fixes your issue.

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