✓ Accepted answer
You probably already fixed this, but just answering so you can mark it as an accepted answer so that people wont look through this question thinking its unanswered.
The ClickDetector.MouseClick() function passes through the object which clicked it (only players because bricks dont have mouse cursors), which you can then use to give the tool to the player.
Example:
function oc(player)
The (player) argument is the object which clicked on it. This can be renamed to anything, as it is just a variable.
Heres an example --v
function oc(player)
local sword = game.ReplicatedStorage.Sword:Clone()
sword.Parent = game.Players[player.Name].Backpack
end
script.Parent.ClickDetector.MouseClick:connect(oc)
2 comments
LocalScript I presume. You can not use LocalPlayer in a server script, and you can not use a LocalScript in a server object. The MouseClicked event does provide the player object who clicked on the brick, so you can utilize that when giving the object.
Oh ok, thanks.