Click to pick up an object

1. What do you want to achieve? Keep it simple and clear!

  • Hello! First time posting here! Basically, I’ve been trying to write a script where:
  • If I click a certain part, existing in the workspace (in this case a tea model) it goes transparent and it goes into my inventory, and if I click on the same spot again it reappears!

2. What is the issue? Include screenshots / videos if possible!

  • My issue is that I cannot figure out how to progress from here, (oh and also the effects don’t disappear when I set their rot speed to ungodly amounts to make them disappear when clicked)

3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

  • I’ve looked on the dev forum many times, at different scripts and I still haven’t been able to figure out anything

Here’s the script:

Anything will be of help, thank you!


Solved, multiple solutions have been posted!


By reading your script, I’ve not seen the part giving the tea, in your place I would use Clone() on a tool in server storage because it appears that’s where you placed it and put the Parent property of the clone to the player’s backpack, the MouseClick event returns the player making that finding the player would not be a problem.

About the putting back the tea part you can check if he haves the tea by using the boolean you made and use Destroy() to take the tea back.

I hope it helps, it’s my first day on the forum.

1 Like
  • Thanks a lot! I’ve made some progress but once again I’ve gotten stuck at the cloning part specifically cloning the Tea into the backpack , here’s what the script looks like now:

  • Here’s the error message as well:

  • I’ve done some research and some people say that it needs to run inside a local script to work, some don’t.

  • Also I don’t think it’ll help but the script worked once the TeaClone.Parent was set to StarterPack, only problem that I had was that I had to reset to get the Tea.

Your variable playerer is nil because calling LocalPlayer only works from a local script. You should be able to remove that line altogether and then just change the first line of your Connect function like so:

click.MouseClick:Connect(function(playerer)
1 Like

@quakage
Alright! It appears in my inventory now! However I’ve found 1 more problem:

  • The TeaClone:Destroy() does not seem to work

use WaitForChild("Backpack")

1 Like

try do Backpack:FindFirstChild("TeaTool"):Destroy()

1 Like

Thanks a lot! Everything works just fine now!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.