Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I make it where a player is limited to 1 of each tool? [closed]

Asked by 3 years ago

How can I make it where a player is limited to 1 of each tool?

0
Or if possible, how can I make it where when someone collects an item, they can never see that item pop-up again? SpiffyYoyo1561 -5 — 3y
0
You need to elaborate a bit, how does the player get the tool in the first place? If they get the tool through a script it would be super easy to check if they already have it. ElongatedMongoose 138 — 3y
0
Yes, once they collect it they can't see it anymore. SpiffyYoyo1561 -5 — 3y
0
It doesn't have to be a tool, I'm trying to make an artifact/treasure hunting game and I wanted it so that every time you find an artifact it goes into a journal and you can go and sell it. SpiffyYoyo1561 -5 — 3y

Closed as Not Constructive by krowten024nabrU, imKirda, and RayCurse

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
0
Answered by 3 years ago

Just check it with :FindFirstChild() everytime the server gives the player a new tool/item Example:

local toolName -- your tool name from remote event/function or something else
local hasTool = player:WaitForChild("Backpack"):FindFirstChild(toolName)

if hasTool then
   warn("player has " ..toolName.. " already!")
else
   -- do whatever you want
end
Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

You can make it so it checks if the player already has that tool for example:

local tool = game.ReplicatedStorage.Tools:WaitForChild("BloxyCola") -- This is just an example

function giveTool(Tool, plr)
    if not plr.Backpack:FindFirstChild(tool) then
        Tool:Clone().Parent = plr.Backpack
        -- Do whatever you want
    else
        warn(plr.Name.." already has "..Tool.Name.."!")
        -- Do whatever you want
    end
end

-- The function must be connected to some kind of event for example
game.Workspace.GiverPart.ClickDetector.MouseClick:Connect(function(playerThatClicked)
    giveTool(tool, playerThatClicked)
end

You can also do it like this

local tool = game.ReplicatedStorage.Tools:WaitForChild("BloxyCola") -- This is just an example

game.Workspace.GiverPart.ClickDetector.MouseClick:Connect(function(plr)
    if not plr.Backpack:FindFirstChild(tool) then
        tool:Clone().Parent = plr.Backpack
        -- Do whatever you want
    else
        warn(plr.Name.." already has "..tool.Name.."!")
        -- Do whatever you want
    end
end

All of this was an example so you should use your imagination and modify the script to your needs but hopefully I helped and you understood what I tried to tell you.

But if this was too complex to you then you can either research more about the things on this script, search for a simpler method or check other answers by other users or if you have any other problem just ask me.