In my game, I am providing bowls of fruit which players can click on to equip a single fruit. I've seen examples of this in other games, such as "Blox Hunt" where players can turn into objects. However for the bowl of fruit, instead of copying the object onto another player, I want to get a single piece of fruit out of the bowl. Is this possible? I am just a beginner, and I don't have any experience in Lua. Thank you!
There are a couple different ways you can go about doing this.
The less efficient way, but still a way, would be to place click detectors in each different fruit and place a script inside that does what you're trying to do, when the fruit is clicked.
Another way would be to make a single LocalScript that detects whenever the player clicks on something. You would then add parameters / if statements to see if the player clicked on a fruit and if they did, it would run a function / do whatever it is you're trying to do with the fruit.
local player = game.Players.LocalPlayer --Gets the player that owns the script local mouse = player:GetMouse() --Gets the player's mouse mouse.Button1Down:connect(function) --When the player clicks print(mouse.Target.Name) --To show what you clicked on ( for testing purposes) if mouse.Target.Name == "Fruit" then --Will only run if what you clicked on is named fruit --Do stuff end end)
You can choose whatever is easier for you or what is best for what you're trying to do. If you need anymore help or have questions just ask.
Hope this helped!