-
What do you want to achieve?
How to make a mesh into a a clickable object that when clicked it gives you one.
(It is food meshes btw)
Sorry about not a lot of info.
Sorry about not a lot of info.
Yup some basic scripting knowledge will be neccesary
So insert a click detector into the mesh and then place the mesh into a tool?
But can it be on a counter and me still click it and get it?
Depends, whats the exact behaviour/system you are looking for?
So first of all before you do any of this you actually need to make them tools, so what i would suggest doing is having the actual meshes of the food out ingame without them actually being tools they are just there for aesthetics.
Now to create the tool you just add a tool object into workspace and then name the part that you want the food to be held from called “Handle” now you need some kind of weld system, there are many easy to use weld scripts available or, you can manually weld them.
So once you have your tool which is the food, you can make a folder in serverstorage or something to hold the tools, but make sure that you name each of them some unique way the reference ill use for one of the tools you might name is “Pizza” which I see you have there.
So now for the clickdetector part
You add clickdetectors to those placeholder meshes in workspace and than if you group them together with the clickdetectors being inside each mesh you can do something like this.
local foodReference = game:GetService("ServerStorage"):WaitForChild("FoodTools")
local model = script.Parent -- this model will hold all of the food placeholders or the stationary things in workspace with the clickdetectors inside them
for i,v in pairs(model:GetChildren()) do
if model:IsA("MeshPart") or model:IsA("Part") then
local clickDetect = model:FindFirstChild("ClickDetector")
if clickDetect then -- make sure it has a clickdetector inside it so there are no errors
clickDetect.MouseClick:Connect(function(player)
if game.Players:FindFirstChild(player.Name) then -- verify that whatever clicked it is a player
local food = foodReference:FindFirstChild(clickDetect.Parent.Name) -- this will look for a food object in the foodtools folder the same name as the food you are clicking
if food then
local newFood = food:Clone()
newFood.Parent = player.Backpack
end
end
end)
end
end
end
I’m not too sure on what you are asking but i think this will steer you in the right direction, if i got confused just reply to this and ill continue to help.
A mesh inside the game which is not a tool, its not only for aesthetics. You can turn that mesh into many systems, without turning it into a tool, by scripting. Place it in players hands, make some functions for it on click and everything. Just, turn it into a tool is the easier/quicker way. But its not mandatory to be a tool :v
I’m still confused. I am not a scripter and I get really confused…
Just mention exactly what you want, probably @BostonWhaIer and me can help you with that perfectly.
@ChristmasKqren. The script he gave you is doing exactly what u asked, juust follow the instructions
I want to be able to click foods and get one
If each food mesh is one part you can just name it whatever the same tool in serverstorage is so if you have a mesh called Pizza and than the tool in serverstorage is called Pizza than your good.
Once you have the mesh named just add a clickdetector inside the mesh and than once all of your food meshes are good you can group them together in workspace and copy and paste the script I sent you as long as the folder containing the tools in serverstorage is called “FoodTools”
You would want to put the script inside of the group of food meshes in workspace
I did the stuff but it won’t give me anything when I click