For example, if I had a bunch of tools lying on the floor called 'Pistol', how would I make it so once a player has one in their inventory, they can't pick up another?
Thanks,
- Sam4550.
For example, if I had a bunch of tools lying on the floor called 'Pistol', how would I make it so once a player has one in their inventory, they can't pick up another?
Thanks,
Well, I'd put the tool as a model in Workspace, not the actual Tool itself. So, you'd have a model that you can't pick up. Then, from there, I'd add a Touched event and put it inside the biggest part if the model. Then, once I have my Touched Event laid out, I'll use the FindFirstChild Method to check if the Player already has it. If not, it'll then clone it and put it in their Backpack.
Tool = "Tool name here"
script.Parent.Touched:connect(function(hit) -- Touched Event w/ the connection line
if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then -- Checks if it's a player
p = game.Players:GetPlayerFromCharacter(hit.Parent) -- Sets the player variable
if not p.Backpack:findFirstChild(Tool) then -- Checks if it is in their backpack. If not, then do the following
copy = game.ServerStorage[Tool]:clone() -- clone the tool
--copy2 = game.ServerStorage[Tool]:clone()
copy.Parent = p.Backpack -- put it in their backpack
--copy2.Parent = p.StarterGear
script.Parent.Parent:Destroy() -- Destroys the fake gun (Model). Make sure this leads to the ACTUAL Model
end
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.