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

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

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!

3 comments

0

Why are you using udim2? Why not use tween?

0

bruh use tween

0

Okay, I'll use that and see if it works out. Sorry lol.

1 answer

✓ Accepted answer
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.

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