im doing this script that creates a square, and the y axis of the square should be random. But it is spawning on the same spot everytime.
How do i fix it?
local function spawnSquare()
local newSquare = square:Clone()
local ypos = math.random(0.1,0.9)
newSquare.Parent = startingFrame
newSquare.Position = UDim2.new(0.5, 0, ypos, 0)
newSquare.Rotation = 45
newSquare.Visible = true
local posTween = TS:Create(newSquare, TweenInfo.new(1, Enum.EasingStyle.Quart, Enum.EasingDirection.In),{Position = UDim2.new(-0.1, 0, newSquare.Position)})
local sizeTween = TS:Create(newSquare.UIScale, TweenInfo.new(1, Enum.EasingStyle.Quart, Enum.EasingDirection.In),{Scale = 2.5})
posTween:Play()
sizeTween:Play()
posTween.Completed:Connect(function()
newSquare:Destroy()
end)
end
wait(5)
repeat
spawnSquare()
wait(0.2)
until 1 == 2 --This is just to test