So basically, I want to make a start screen where image labels will fly across the screen, random image labels will fly across the screen to random position, from left to right.
My problem is because of my limited experience with scripting, I can’t seem to get a random gui and make it fly across to a random position
What have I tried?
I tried tables, for loops etc. I don’t if I messed up or if they just don’t work.
Video: https://gyazo.com/c059b266a9475189852c8f66d88647f1
basically only one appears at a time and also they keep following the same pattern
My current script:
local RunService = game:GetService("RunService")
function lerp(a, b, c)
return a + (b - a) * c
end
function quadBezier(t, p0, p1, p2)
local l1 = lerp(p0, p1, t)
local l2 = lerp(p1, p2, t)
local quad = lerp(l1, l2, t)
return quad
end
function tweenObject(object, pos1, pos2, pos3)
for i = 1, 100 do
local t = i/100
local XScale = quadBezier(t, pos1.X.Scale, pos2.X.Scale, pos3.X.Scale)
local YScale = quadBezier(t, pos1.Y.Scale, pos2.Y.Scale, pos3.Y.Scale)
local XOffset = quadBezier(t, pos1.X.Offset, pos2.X.Offset, pos3.X.Offset)
local YOffset = quadBezier(t, pos1.Y.Offset, pos2.Y.Offset, pos3.Y.Offset)
object.Position = UDim2.new(XScale, XOffset, YScale, YOffset)
RunService.RenderStepped:Wait()
end
end
while true do
local template1 = script.Parent.Template1:Clone()
template1.Parent = script.Parent
template1.Visible = true
tweenObject(template1, UDim2.new(0, 0,0.92, 0), UDim2.new(0.496, 0,0.122, 0), UDim2.new(0.951, 0,0.931, 0))
template1:Destroy()
local template2 = script.Parent.Template2:Clone()
template2.Parent = script.Parent
template2.Visible = true
tweenObject(template2,UDim2.new(-0.03, 0,0.647, 0),UDim2.new(0.476, 0,-0.035, 0),UDim2.new(0.983, 0,0.485, 0))
template2:Destroy()
local template3 = script.Parent.Template3:Clone()
template3.Parent = script.Parent
template3.Visible = true
tweenObject(template3,UDim2.new(0.59, 0,0.952, 0),UDim2.new(0.649, 0,0.573, 0),UDim2.new(0.978, 0,0.634, 0))
template3:Destroy()
end
yes I know I could keep cloning and changing the cords but I feel like there is better way that I am not aware of.