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

How do I make a giver script that if the player has the tool already, it is not given?

Asked by 8 years ago

This is my script so far, it can be spammed for infinite tools, how do I make it so that if the player already has said tool, it isn't given to the player?

plr = game.Players.LocalPlayer
tool = game.ServerStorage["Knife"]

script.Parent.MouseButton1Down:connect(function()
    tool:clone().Parent = plr.Backpack
end)

Thanks!

0
You called use a debounce, or just check their backpack and make sure they don't have another copy of the tool. NinjoOnline 1146 — 8y
0
But how do I check the backpack? PieceOfPurple 5 — 8y

2 answers

Log in to vote
2
Answered by 8 years ago

Use FindFirstChild to check for the tool.

plr = game.Players.LocalPlayer
tool = game.ServerStorage["Knife"]

script.Parent.MouseButton1Down:connect(function()
if plr.Backpack:FindFirstChild("Knife") == nil then
    tool:clone().Parent = plr.Backpack
else return end
end)

Something like this I think

0
I was halfway through making another script, this is much more efficient. PieceOfPurple 5 — 8y
0
Pretty sure that code you just wrote would let them get two knifes, if they hold the tool. When a tool is held in the hand, its in the character instead of the backpack. You'd have to check both of them joalars2 107 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

Debounce This wiki should help you out with your problem

Answer this question