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

How to make a script repeat itself?

I am wandering how i can make this script repeat:


for i=1, 10 do
wait(5)
	local players = game.Players:GetChildren()
	print(#players)
	if #players >= 1 then
		local murder = players[math.random(1,#players)]
		local Knife = game.Lighting.Knife:Clone()
		Knife.Parent = murder.Backpack
		wait(10)
		end
	end

It keeps doing the wait(10) one, not going back to wait(5) then ten and again. Please help i am new at all this and am trying to make a game.

2 comments

1

Can you please edit your post to use the Lua code formatting feature?

0

Hi i did what you asked!

1 answer

The best way to do this is by using

while true do
-- your script here

2 comments

0

Hey, i have tried that but it still does ten over and over instead of starting completely over again and agian.

0

A simple answer to this is to make 10 equal something like the letter i does. Make j = 10 or something

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