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

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

Asked by 9 years ago

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

Log in to vote
-1
Answered by
Ywis 5
9 years ago
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

0
no problem im a beginner too FastSnail5 8 — 9y
0
thanks, tell me if it works! :) Ywis 5 — 9y
0
it didnt work but at least u tried FastSnail5 8 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

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.

Answer this question