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

Using Udim2 to move images, clone a child, then destroy?

Asked by 3 years ago

Hello! I'm making a game where you have to get teleported to another place to participate in rounds. During this you're greeted with a custom teleport screen with images that are meant to move down your screen. The script is meant to move an image down the screen, wait 10 seconds, clone a random child in the 'Images' folder, then finally destroy. Thus making a loop.

Keep in mind the script below is in each and every image in the 'Images' folder, the folder is in a ScreenGui under StarterGui. (Sorry if that confuses you.)

The problem I'm having trouble with:

After moving the images down for 10 seconds, I can't seem to get it to clone another image in the folder.

The script:

script.Parent.Images.Position = script.Parent.Position - UDim2.new(0,0,0,-0.01)

wait(10)

local items = script.Parent.Parent:GetChildren()
local randomItem = items[math.random(1, #items)]

local PickedItem = math.random(1, #items)

PickedItem:Clone()
wait()
script.Parent:Destroy()

I know there are mistakes in here, and yes it's trash but you've got to start somewhere...

Any help is appreciated. Thank you!

0
Why are you using udim2? Why not use tween? Cynical_Innovation 595 — 3y
0
bruh use tween CandyWreckEpicness 115 — 3y
0
Okay, I'll use that and see if it works out. Sorry lol. ROBLOX_sammy048 28 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago
script.Parent.Images.Position:TweenPosition(UDim2.new(script.Parent.Position) - UDim2.new(0,0,0,-0.01)))

wait(10)

local items = script.Parent.Parent:GetChildren()
local randomItem = items[math.random(1, #items)]

local PickedItem = math.random(1, #items)

PickedItem:Clone()
wait()
script.Parent:Destroy()

Tell me if it works or not and I will fix It.

Ad

Answer this question