So pretty much whenever someone rolls a legendary or mythic I want the text to the a slightly back and forth rotation however for some reason even when the chosenrank is still legendary or mythic it ends the loop. Also when the PosTween finishes it goes instantly to the neg tween without tweeting
local RollButton = script.Parent.RollButton
local RS = game:GetService("ReplicatedStorage")
local Database = require(RS.Database)
local plr = game.Players.LocalPlayer
local LuckMulti = 10
local LuckPerRolls = 10
local function GenerateRNG()
local totalWeight = 0
for Rank, Data in pairs(Database) do
if plr.leaderstats.Rolls.Value % LuckPerRolls == 0 then
print("Lucky Roll")
if Data.LuckBoostable then
totalWeight = totalWeight + Data.Chance * LuckMulti
else
totalWeight = totalWeight + Data.Chance
end
else
totalWeight = totalWeight + Data.Chance
end
end
local randomNumber = Random.new():NextNumber(0, totalWeight)
local weightSum = 0
for Rank, Data in pairs(Database) do
if plr.leaderstats.Rolls.Value % LuckPerRolls == 0 then
if Data.LuckBoostable then
weightSum = weightSum + Data.Chance * LuckMulti
else
weightSum = weightSum + Data.Chance
end
else
weightSum = weightSum + Data.Chance
end
if randomNumber <= weightSum then
local RankVal = math.round(Random.new():NextNumber(Database[Rank].ValRange[1],Database[Rank].ValRange[2]) * 100) / 100
return Rank, RankVal
end
end
end
local RankRevealFrameHolder = script.Parent.RankRevealFrameHolder
local RankRevealFrameHolderPositions = {
In = UDim2.new(0, 0,-1, 0);
Out = UDim2.new(0, 0,0, 0);
};
local db = false
local TS = game:GetService("TweenService")
local TweenStyle = TweenInfo.new(0.3,Enum.EasingStyle.Exponential,Enum.EasingDirection.InOut)
local HighRankUIDesigns = RS.HighRankUIDesigns
local RankDisplay = RankRevealFrameHolder.RankRevealFrame.RankDisplay
local ValueDisplay = RankRevealFrameHolder.RankRevealFrame.ValueDisplay
local RankColors = {
["Common"] = Color3.fromRGB(97, 255, 89);
["Uncommon"] = Color3.fromRGB(87, 222, 77);
["Rare"] = Color3.fromRGB(0, 115, 255); -- old color 0,98,255
["Epic"] = Color3.fromRGB(185, 0, 185);
["Legendary"] = Color3.fromRGB(255, 193, 60);
["Mythic"] = Color3.fromRGB(202, 137, 255);
};
local RankPriorities = {
["None"] = 0;
["Common"] = 1;
["Uncommon"] = 2;
["Rare"] = 3;
["Epic"] = 4;
["Legendary"] = 5;
["Mythic"] = 6;
}
local RewardPlrRoll = RS.RemoteEvents.RewardPlrRoll
local AddRoll = RS.RemoteEvents.AddRoll
local RolledRankOptionsHolder = RankRevealFrameHolder.RolledRankOptionsHolder
local ChosenRank, ChosenRankVal
local RollButtonNormSize = RollButton.Size
local RollComplete
local function Roll()
db = true
AddRoll:FireServer()
TS:Create(RollButton,TweenStyle,{Size = RollButtonNormSize - UDim2.fromScale(0.0162,0.0023)}):Play()
RollButton.TextColor3 = Color3.fromRGB(205, 205, 205)
TS:Create(RankRevealFrameHolder,TweenStyle,{Position = RankRevealFrameHolderPositions.Out}):Play()
local Rolls = 0
repeat
Rolls += 1
ChosenRank, ChosenRankVal = GenerateRNG()
RankRevealFrameHolder.RankRevealFrame.BorderLine.Color = RankColors[ChosenRank]
RankDisplay.Text = ChosenRank
ValueDisplay.Text = tostring(ChosenRankVal)
if ChosenRank == "Legendary" or ChosenRank == "Mythic" then
RankDisplay.TextColor3 = Color3.fromRGB(255,255,255)
if RankDisplay:FindFirstChildWhichIsA("UIGradient") and RankDisplay:FindFirstChildWhichIsA("UIStroke") then
RankDisplay:FindFirstChildWhichIsA("UIGradient"):Destroy()
RankDisplay:FindFirstChildWhichIsA("UIStroke"):Destroy()
end
if not RankDisplay:FindFirstChildWhichIsA("UIGradient") and not RankDisplay:FindFirstChildWhichIsA("UIStroke") then
local ClonedGradient = HighRankUIDesigns:FindFirstChild(ChosenRank).Gradient:Clone()
ClonedGradient.Parent = RankDisplay
local ClonedTextOutline = HighRankUIDesigns:FindFirstChild(ChosenRank).TextOutline:Clone()
ClonedTextOutline.Parent = RankDisplay
end
else
RankDisplay.TextColor3 = RankColors[ChosenRank]
if RankDisplay:FindFirstChildWhichIsA("UIGradient") and RankDisplay:FindFirstChildWhichIsA("UIStroke") then
RankDisplay:FindFirstChildWhichIsA("UIGradient"):Destroy()
RankDisplay:FindFirstChildWhichIsA("UIStroke"):Destroy()
end
end
task.wait(0.25)
until Rolls == 5
task.wait(1)
local PlrRankPriority = RankPriorities[plr.leaderstats.Rank.Value]
local ChosenRankPriority = RankPriorities[ChosenRank]
if PlrRankPriority == ChosenRankPriority then
local PlrRankVal = plr.leaderstats.Value.Value
if PlrRankVal < ChosenRankVal then
RankRevealFrameHolder.RolledRankOptionsHolder.Visible = true
RankRevealFrameHolder.RolledRankOptionsHolder.LeftOption.RewardType.Value = "RankVal"
else
TS:Create(RollButton,TweenStyle,{Size = RollButtonNormSize}):Play()
RollButton.TextColor3 = Color3.fromRGB(239, 239, 239)
TS:Create(RankRevealFrameHolder,TweenStyle,{Position = RankRevealFrameHolderPositions.In}):Play()
task.wait(0.3)
db = false
end
elseif PlrRankPriority < ChosenRankPriority then
RankRevealFrameHolder.RolledRankOptionsHolder.Visible = true
RankRevealFrameHolder.RolledRankOptionsHolder.LeftOption.RewardType.Value = "Overall"
else
TS:Create(RollButton,TweenStyle,{Size = RollButtonNormSize}):Play()
RollButton.TextColor3 = Color3.fromRGB(239, 239, 239)
TS:Create(RankRevealFrameHolder,TweenStyle,{Position = RankRevealFrameHolderPositions.In}):Play()
task.wait(0.3)
db = false
end
local CustomTS = TweenInfo.new(2,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut)
local NegTween
local PosTween
repeat
NegTween = TS:Create(RankDisplay,CustomTS,{Rotation = -2.5})
NegTween:Play()
task.wait(2)
PosTween = TS:Create(RankDisplay,CustomTS,{Rotation = 2.5})
PosTween:Play()
task.wait(2)
until ChosenRank ~= "Legendary" or ChosenRank ~= "Mythic" -- RankDisplay.Text ~= "Legendary" or RankDisplay.Text ~= "Mythic"
print(ChosenRank)
NegTween:Cancel()
PosTween:Cancel()
RankDisplay.Rotation = 0
end
RollButton.MouseButton1Click:Connect(function()
if not db then
Roll()
end
end)
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input,GPE)
if not GPE then
if input.UserInputType == Enum.UserInputType.MouseButton1 then
if not db then
Roll()
end
end
end
end)
local LeftOption = RolledRankOptionsHolder.LeftOption
LeftOption.MouseButton1Click:Connect(function()
if LeftOption.RewardType.Value == "RankVal" then
RewardPlrRoll:FireServer(LeftOption.RewardType.Value,ChosenRankVal)
elseif LeftOption.RewardType.Value == "Overall" then
RewardPlrRoll:FireServer(LeftOption.RewardType.Value,ChosenRank,ChosenRankVal)
end
RankRevealFrameHolder.RolledRankOptionsHolder.Visible = false
TS:Create(RollButton,TweenStyle,{Size = RollButtonNormSize}):Play()
RollButton.TextColor3 = Color3.fromRGB(239, 239, 239)
TS:Create(RankRevealFrameHolder,TweenStyle,{Position = RankRevealFrameHolderPositions.In}):Play()
task.wait(0.3)
db = false
end)
Issue:
repeat
NegTween = TS:Create(RankDisplay,CustomTS,{Rotation = -2.5})
NegTween:Play()
task.wait(2)
PosTween = TS:Create(RankDisplay,CustomTS,{Rotation = 2.5})
PosTween:Play()
task.wait(2)
until ChosenRank ~= "Legendary" or ChosenRank ~= "Mythic"
robloxapp-20240506-2245424.wmv (411.3 KB)