Hi there! I made a script that gives a player an item when they click it, and it works. But it only gives them the item once and then stops working. Here is my script:
1 | local tool = game.ServerStorage.Card |
2 | local klone = tool:clone |
3 | script.Parent.ClickDetector.MouseClick:connect ( function (plr) |
4 | if klone.Parent ~ = plr.Backpack then |
5 | klone.Parent = plr.Backpack |
6 | else |
7 | end |
8 | end ) |
Can somebody help me?
So in this script, there is an if-then statement
that checks if you currently have the item. If you remove the statement, then it should fix it.
1 | local tool = game.ServerStorage.Card |
2 | local klone = tool:clone |
3 | script.Parent.ClickDetector.MouseClick:connect ( function (plr) |
4 | klone.Parent = plr.Backpack |
5 | else |
6 | end ) |
Here you go.
01 | script.Parent.ClickDetector.MouseClick:connect ( function (plr) |
02 | local tool = game.ServerStorage.Card:Clone() |
03 | if tool.Parent ~ = plr.Backpack then |
04 | tool.Parent = plr.Backpack |
05 | else |
06 | tool:Destroy() |
07 | warn( "This player already has the tool!" ) |
08 | return |
09 | end |
10 | end ) |