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

Make a player limited to 1 of each tool?

Asked by 2 years ago
Edited 2 years ago

Hi :), I made an tool giver, but I want that the player only has one of each tool (in this case a knife). I tried multiple things, but never worked. Someone that can help me?

this is the script of the tool giver with clickdetector

function hi(x)
    local y = x.Backpack
    local z = game.Lighting["Knife"]
    z:Clone().Parent = y
end

script.Parent.ClickDetector.MouseClick:connect(hi)

1 answer

Log in to vote
1
Answered by
Puppynniko 1059 Moderation Voter
2 years ago
Edited by imKirda 2 years ago
function hi(x)
    local y = x.Backpack
    if y:FindFirstChild("Knife") or x.Character:FindFirstChild("Knife") then return end
    local z = game.Lighting["Knife"]
    z:Clone().Parent = y
end

script.Parent.ClickDetector.MouseClick:connect(hi)
0
Ty, but now it dont give me the knife anymore. iiDark_St4le 19 — 2y
1
i edited my answer, check if it works now! :) imKirda 4491 — 2y
0
very uncool mate Puppynniko 1059 — 2y
0
It worked!!! TY SO MUCH iiDark_St4le 19 — 2y
View all comments (3 more)
0
shame on you for misspelling variables imKirda 4491 — 2y
0
who uses X and Y was variables :( Puppynniko 1059 — 2y
0
I copied a script with those variables because I was struggling to make my own iiDark_St4le 19 — 2y
Ad

Answer this question