Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Script only giving tool once and I want to to give it an infinite amount of times?

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.

1 answer

✓ Accepted answer

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.

2 comments

0

Thank you, it works perfectly

0

it should be tool:Clone() instead of tool:clone()

This discussion is preserved as it was. New answers, comments, and votes are closed.