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.
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)
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.
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.