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

How do i make this happen a certain amount of times?

script.Parent.MouseClick:connect(function(plr)

local c = game.Lighting.Apple:Clone()

c.Parent = plr.Backpack

end)

So I kind of asked this question earlier i suppose. anyways Timster111 helped me come this far with my script but now I need a tree that i already have in my game to give the character the apple only 2 times per 5 minutes. can anyone help me?

2 answers

✓ Accepted answer
while true do
wait(300) -- amount of seconds for this to happen
local c = game.Lighting.Apple:Clone()

c.Parent = plr.Backpack
end

Try that, might work.

beginner scripter ywis

3 comments

0

no problem im a beginner too

0

thanks, tell me if it works! :)

0

it didnt work but at least u tried

Maybe this?

local clock = 0

function giveApple()
for i=1, 2 do
local apple = game.Lighting.Apple:clone()
apple.Parent = plr.Backpack
end
end
--if you want it to give them an apple right away, just put giveApple() here

while wait(1) do
clock = clock + 1
if clock == 300 then
giveApple()
clock = 0
end
end

That should work, although I can't test it right now.

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