How to make an item that will give it to you if you click on it and again?
Asked by
5 years ago Edited 5 years ago
Hi everyone. Recently I have been making an airport lounge for my airline, and I want to make it good as people are paying for it, so I have been trying to make food you can pick up by clicking on it. I have tried many ways to do this. Some ways worked, but when someone clicks on the food they will get but if you click on it again it won't give you anything. I have been trying to figure this out for the past couple of days but still have no solution.
Here is the code that I found worked the best:
`local ToolNames = {"Toast"} -- Tool names
local Storage = game:GetService("ServerStorage") -- Tool storage
local Part = script.Parent
local ClickDetector = Part:WaitForChild("ClickDetector")
ClickDetector.MouseClick:connect(function(Player)
if Player and Player.Character then
local Backpack = Player:WaitForChild("Backpack")
for i = 1, #ToolNames do
local Tool = Storage:FindFirstChild(ToolNames[i])
if Tool then
1 | local already = Player.Backpack:FindFirstChild(ToolNames [ i ] ) |
5 | Tool:clone().Parent = Backpack |
end
end
end
end)
`
~~~~~~~~~~~~~~~~~