New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
1

# How do I provide a random objects to equip?

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!

0
Wait, you want the fruit the be randomized or they can click on whatever fruit they specifically want? StoIid 354 — 3y
0
They can click whatever fruit they specifically want. For example, there is a bowl of apples. After clicking the bowl, they only get one apple. crystalclay 70 — 3y

0
StoIid 354
3 years ago

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.

Info and Example On Click Detectors

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.

Ex:

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!

0
Thank you so much! crystalclay 70 — 3y