Help with a script

  1. I commissioned a Modeler, @Red1Monster, his job was amazing! Now, I want to receive the food in my inventory when I click on the model.

  2. Pratically, using my script, I need a tool which is located in ServerStorage for it to work.

  3. I haven’t a tool, but I only have the mesh part, and I don’t know how to solve this. Below you can find my code:


script.Parent.MouseClick:Connect(function(Plr)

Item:Clone().Parent = Plr.Backpack

end)```
2 Likes

You must have a ClickDetector.

1 Like

I have, inside the clickdetector I put the script.

Add a script inside the Part and type this in it:

local Part = script.Parent.GivePart
local CD = script.Parent.ClickDetector
local Tool = --Tool location here.

CD.MouseClick:Connect(function(PlayerWhoClicked)
	local ClonedTool = Tool:Clone()
	ClonedTool.Parent = PlayerWhoClicked.Backpack
end)

EDIT: Remove the script from the ClickDetector and add the Script to the Part that the Player must Click it to get the Tool.

1 Like

That has to be in a ServerScript, otherwise the script cannot view the content of ServerStorage.

So, to make it simple the player will get the specified tool when the clickDetector is triggered.

Firstly, you need without exception a tool, you can directly build one in your script.

local SStorage = game:GetService("ServerStorage")
local displayedMesh = script.Parent.Parent -- the name of that mesh will be used to index the tool in SStorage
local clickDetector = script.Parent

clickDetector.MouseClick:Connect(function(plr)
       local requestedTool = SStorage:FindFirstChild(displayedMesh.Name)

      if requestedTool then
            local tool = Instance.new("Tool")

            local meshClone = displayedMesh:Clone()

            mesh.Parent = tool
            mesh.Anchored = false
            mesh.Name = "Handle"

            tool.Parent = plr.Backpack
      else
            warn("Couldn't find the tool)
      end
end)
1 Like

I made extremely simple script.

game.Workspace.Part.ClickDetector.MouseClick:Connect(function(plr)

game.ServerStorage.Tool:Clone().Parent = plr.Backpack

end)

I have tried this and it worked!

Greetings @SubbIezHolder, sorry for that! I just fixed the full script and tested it:

local Part = script.Parent
local CD = Part.ClickDetector
local Tool = game.ServerStorage -- Put yoru tool's Location here

CD.MouseClick:Connect(function(PlayerWhoClicked)
	local ClonedTool = Tool:Clone()
	ClonedTool.Parent = PlayerWhoClicked.Backpack
end)

Thank you,
Abd

EDIT: Remember to put the script in the Part that you want the Player to click to get the tool.

I do not have a tool in serverstorage! I have only the mesh part.

You must have a Tool, because when the player click the Part they can’t get a MeshPart.
You can’t make the Player get a MeshPart.

  1. Clone your mesh part.
  2. Make a Tool.
  3. Name the mesh part’s clone Handle and put it in the Tool.
  4. Name the Tool.
  5. Put the Tool in ServerStorge.

Yes, but idk how to make a tool.

It’s not working…[30]…

Click on the white button next to “StarterPack” and click on tool.
Then get your mesh and name it Handle. Make sure the mesh is parented in your tool.
You should Install the Tool Grip Editor Plugin to adjust the position of your handle.