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

How would I go about cloning a Gui and managing 10 instances?

Asked by 4 years ago

Hello, I'm trying to work on a speed indicator for a flight simulator. Sort of like the flightline speed indicator, and those in real life. I think I have the concept solid: have different gui "cells", each being a blank template of the speed segments. I would clone them to fill the area, and when they go off screen, delete the clone, or when needed, clone them in. I would then use a tween animation to make it scroll smoothly. I hope that makes sense in a way. My code so far determines how many cells can fit on the screen, and then center the first one.

-- Reference to Gui
local cell = script.Parent.SpeedCell
local boundaries = script.Parent.Background

-- Do some math to determine how many cells can fit on the screen, then position main cell in the middle.
local cellHeight = cell.Size.Y.Offset
local boundaryHeight = boundaries.Size.Y.Offset
local cellAmount = math.floor(boundaryHeight/cellHeight)
local centerY = Vector2.new(workspace.CurrentCamera.ViewportSize / 2)
cell.Position = UDim2.new(cell.Position.X.Scale,cell.Position.X.Offset,.5,cell.Position.Y.Offset)

My main question is how I should go about managing, say 10 clones and deleting them or creating new ones quickly. Again, I hope this makes sense. Thank you for your time

Answer this question