GUI Animation not working properly

Hello, I have an animation module here for my gui that is meant to pick random things from a table to appear in the roll animation. Everything works fine apart from the fact that it only picks the selected one (that they are actually going to get) and replays that. How can I make it choose random things sorta like a case opening animation.

Animation Module:

local TweenService = game:GetService('TweenService')

local info = TweenInfo.new(.2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)

local function animateText(text1, text2, roll, RollInfo)
	text1.Position = UDim2.fromScale(.404, 0.096)
	text1.Text = roll
	text2.Text = '1 in '..RollInfo[roll].weight
	
	
	TweenService:Create(text1, info, {Position = UDim2.fromScale(.404, .415)}):Play()
	wait(.2)
end

return {
	rollAnimation = function(RollGui, roll, RollInfo)
		local RollingFrame = RollGui
		local Auras = require(game.ReplicatedStorage.Auras)
		local RollText = RollGui:WaitForChild('AuraLabel')
		local Chance = RollGui:WaitForChild('ChanceLabel')
		
		RollingFrame.Visible = true
		RollText.Visible = true
		
		for i, Table in pairs(Auras) do
			animateText(RollText, Chance, roll, Auras)
		end
		
		wait(1)
		
		RollingFrame.Visible = false
		RollText.Visible = false
	end,
}

image
image
(the animation only says cyclone over and over)

text1.Text = roll
Create an array of rewards. While the animation is playing periodically select randomly from that array.

local rewards = {"Cyclone", "Hurricane", "Typhoon"}
local randomReward = rewards[math.random(#rewards)]
text1.Text = randomReward

When the animation is finished display the actual reward.
text1.Text = reward

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.