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

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

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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.

0
Thank you, it works perfectly MoralArsonism 47 — 4y
0
it should be tool:Clone() instead of tool:clone() AnasBahauddin1978 715 — 4y
Ad

Answer this question