Hi, I am creating a script which is activated once a player clicks on the brick. The brick gives a tool called 'Beans'. This works fine when I test it, however, when I click the brick again, it does not give me another 'Beans'. Also, when I die and try to collect the beans I get an error in the output saying 'The Parent property of Beans is locked, current parent: NULL, new parent Backpack'. I'm not too sure how to fix that. I would like it so that the player can have as many 'Beans' as they want. I would appreciate it if someone would tell me where I am going wrong. This is the script I have:
local tool = game.ServerStorage:WaitForChild("Beans")
local IGBeans = game.Workspace.IGBeans
local IGBeansD = IGBeans.Decal
local clone = tool:Clone()
IGBeans.ClickDetector.MouseClick:connect(function(plr)
clone.Parent = plr.Backpack
IGBeans.Transparency = 1
IGBeans.Decal.Transparency = 1
wait(240)
IGBeans.Transparency = 0
IGBeans.Decal.Transparency = 0
end)
So I have made it so that the beans disappear when collected, but after 240 seconds I would like the player to be able to collect them again, even if they already have the tool. Thanks in advance.

1 comment
Make another part with the same script, place both parts into each other, or make half of it one part, and half the other part (size)