I'm making a dinner, I have food on plates around on random tables and want you to be able to click on the food and get it given to you. This is the script I have
local tool = game.ServerStorage.Burger -- Burger is the food item I want given local clone = tool:clone() script.Parent.ClickDetector.MouseClick:Connect(function(plr) if clone.Parent ~= plr.Backpack then clone.Parent = plr.Backpack else end end)
It only gives the tool once and then wont give it again, I want players to be able to take it an unlimited amount.
first of all you gotta put the clone in the function:
local tool = game.ServerStorage.Burger -- Burger is the food item I want given script.Parent.ClickDetector.MouseClick:Connect(function(plr) local clone = tool:clone() clone.Parent = plr.Backpack -- you can skip the check btw end)
else it would create only one clone for the entire runtime, thus only one burger.