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

limit same tool in backpack? [closed]

Asked by 4 years ago
Edited 4 years ago

so i need a script and I can't find it anywhere. And I am noob at writing script so i can't write it. Does anyone have this script?

(ex. if player 1 has a tool name 'sword' , then he can't get it anymore.)

0
How does the player recieve it? Shop? Item giver? YazaTheGreat 5 — 4y

Closed as Not Constructive by imKirda, Soban06, and WizyTheNinja

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?

3 answers

Log in to vote
0
Answered by 4 years ago

https://scriptinghelpers.org/questions/109392/how-to-limit-1-of-each-tool-in-a-players-backpack

this post should answer that

Ad
Log in to vote
0
Answered by 4 years ago

imma assume that when a player touch a brick, the game gives them a sword


local Sword = game.ServerStorage.Sword --- or where ever the sword tool is stored local SwordString = tostring(Sword) script.Parent.Touched:Connect(function(player) -----This script must be in the part which is desired to give the sword local backpack = game.Players[player.Name]:WaitForChild("Backpack") if backpack:FindFirstChild(SwordString) then --- checking for sword in the player print("player already has item") --- code that fire if there is already a sword else local SwordCopy = Sword:Clone() --- if there isn't a sword, copy the original SwordCopy.Parent = backpack --- set the parent of the sword to the player's backpack end )

If you need anymore questions, reply to this

Log in to vote
0
Answered by
Soban06 410 Moderation Voter
4 years ago

It's pretty simple. When you give them the sword, you make a check inside their backpack to see if that item already exists. You could do something like this:

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        -- Now we will first check if they already own the item.
        if not player.Backpack:FindFirstChild("ItemNameHere") then
            ItemName:Clone().Parent = player.Backpack
        end
    end
end)

Hope it helped.