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

Is there a way to...?

Is there a way to get this script of mine not to freeze up my computer when I try to run it?

Amount = 5 -- How many will be made.
Fade = false -- Will it/they fade?
Fade_Time = 5 -- How long will it take for it/them to fade.
instance = "StockSound" -- The instance being made.
parent = game -- Where the instance will end up.
Time_Taken = 1 -- The Time it takes for a/each instance to be made.
IDs = false -- Will there be IDs?

--[[ Do not mess with the code below unless you know what you are doing! ]]--

local Holder = Instance.new("Model", parent) Holder.Name = "Holder"

local Total = 0

repeat
if IDs then
Total = Total + 1
local thing = Instance.new(instance, Holder)
thing.Name = instance .. " " .. Total .. " out of " .. Amount
wait(Time_Taken / 1/2)
if Fade then
	game:GetService("Debris"):AddItem(thing, Fade_Time)
	game:GetService("Debris"):AddItem(Holder, Fade_Time * Amount / 1/2)
	wait(Time_Taken / 1/2)
elseif IDs and Fade == false then
	wait(Time_Taken / 1/2)
if IDs == false then
Total = Total + 1
local thing = Instance.new(instance, Holder)
thing.Name = instance
wait(Time_Taken / 1/2)
if Fade then
	game:GetService("Debris"):AddItem(thing, Fade_Time)
	game:GetService("Debris"):AddItem(Holder, Fade_Time * Amount / 1/2)
	wait(Time_Taken / 1/2)
else
	wait(Time_Taken / 1/2)
end
end
end
end
until
Total == Amount
  • it is meant to generate instances with the in-script settings!

1 answer

✓ Accepted answer

Its because you didn't add a wait time after "repeat" which makes it an infinite loop that has no wait time.

This should fix your script:

Amount = 5 -- How many will be made.
Fade = false -- Will it/they fade?
Fade_Time = 5 -- How long will it take for it/them to fade.
instance = "StockSound" -- The instance being made.
parent = game -- Where the instance will end up.
Time_Taken = 1 -- The Time it takes for a/each instance to be made.
IDs = false -- Will there be IDs?

--[[ Do not mess with the code below unless you know what you are doing! ]]--

local Holder = Instance.new("Model", parent) Holder.Name = "Holder"

local Total = 0

repeat
wait(1) --change to the time you want to wait after every loop.
if IDs then
Total = Total + 1
local thing = Instance.new(instance, Holder)
thing.Name = instance .. " " .. Total .. " out of " .. Amount
wait(Time_Taken / 1/2)
if Fade then
    game:GetService("Debris"):AddItem(thing, Fade_Time)
    game:GetService("Debris"):AddItem(Holder, Fade_Time * Amount / 1/2)
    wait(Time_Taken / 1/2)
elseif IDs and Fade == false then
    wait(Time_Taken / 1/2)
if IDs == false then
Total = Total + 1
local thing = Instance.new(instance, Holder)
thing.Name = instance
wait(Time_Taken / 1/2)
if Fade then
    game:GetService("Debris"):AddItem(thing, Fade_Time)
    game:GetService("Debris"):AddItem(Holder, Fade_Time * Amount / 1/2)
    wait(Time_Taken / 1/2)
else
    wait(Time_Taken / 1/2)
end
end
end
end
until
Total == Amount

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