Running it for a certain amount of time...you can use a variable and add onto every second, and then use an if then statement to determine if the variable is the amount of seconds that have passed, then using break to break the loop
For example;
local spawnamount = game.Workspace.Live.spawnamount.Value
local multiplier = 20
local shrieker = game.ReplicatedStorage.Shrieker
local seconds = 0
while true do
wait(1)
seconds = seconds + 1
if seconds == 6 then
break
else
local shriekerclone = shrieker:Clone()
shriekerclone.Parent = workspace
shriekerclone.HumanoidRootPart.Position = game.Workspace.spawnpart.Position
end
end
Though I took the format you used, while true do, you can also use the repeat - until loop
Example;
local spawnamount = game.Workspace.Live.spawnamount.Value
local multiplier = 20
local shrieker = game.ReplicatedStorage.Shrieker
local seconds = 0
repeat
seconds = seconds + 1
local shriekerclone = shrieker:Clone()
shriekerclone.Parent = workspace
shriekerclone.HumanoidRootPart.Position = game.Workspace.spawnpart.Position
wait(1)
until seconds == 6
Links:
https://developer.roblox.com/en-us/articles/Conditional-Statements-in-Lua
https://developer.roblox.com/en-us/articles/Loops
Hope this helps
3 comments
use an if statement and then put break inside it, just the word break
well obviously, I need to know how I can break it after a certain amount of times the loop has played
A for loop