I'm trying to recreate flappy bird in roblox ,i made a function that will clone the pipes:
--here it will pick a random position with a random offset from -7 to 7 from the center of the screen local function Center() local Num = math.random(6.5,20.5) return Num end ------------------------------------------------------------------- --here i made a function that will position the pipes as a pair and have a random offfset around the center Y coordinate local function MakePillar() local newNum = Center() local points = {} local model = Instance.new("Model",game.Workspace.PillarsFolder) model.Name = "Pillars" local newPillar = Pillar:Clone() newPillar.Name = "newPillar" newPillar.Parent = model newPillar.Size = Vector3.new(3,newNum -Distance,3) newPillar.Position = Vector3.new(offset,newPillar.Size.Y/2 - Distance,0) points[1] = newPillar local newPillar2 = Pillar:Clone() newPillar2.Name = "newPillar2" newPillar2.Parent = model newPillar2.Size = Vector3.new(3,27 - newNum - Distance,3) newPillar2.Position = Vector3.new(offset,(27 - newPillar2.Size.Y/2)+Distance,0) points[2] = newPillar2 return points end
and here is the function that spawn the pipes and tween it:
local function tweenPart(part, sec, goal) local tweenInfo = TweenInfo.new(sec, Enum.EasingStyle.Linear, Enum.EasingDirection.Out) local tween =tweenService:Create(part, tweenInfo, goal) tween:Play() end -------------------------------------------------------------------- --Spawn Pillars local function SpawnPillars() local Parts = MakePillar() for i=1, #Parts do tweenPart(Parts[i], 15, {Position = Parts[i].Position - Vector3.new(60,0,0)}) end end
until here everything work fine but then i put the spawn function in a loop and it will spawn pipes every 3.5 seconds, and it did work, but for some reason sometimes it spawns pipes in less than 3.5 sec, only sometimes, and not always, here is the script:
local function Pillars() while dead == false do SpawnPillars() wait(3.5) end end spawn(Pillars)
Does anyone have any idea why this happen? Also here is the game link if u want to see the glitch, i believe u will understand what am saying after u saw it: https://web.roblox.com/games/5222604679/Flappy-Guy
Any help is appreciate, thankyou