Well I’m putting a Rank text through Overhead/Billboard Gui’s and I want to shorten “if” and “elseif” statements than adding tons of them, I don’t know how to ModuleScript this too
Clicks:GetPropertyChangedSignal("Value"):Connect(function()
if Clicks.Value >= 5 then
CloneOverhead.Frame.ClickRank.Text = "Pro"
elseif Clicks.Value >= 4 then
CloneOverhead.Frame.ClickRank.Text = "Epic"
elseif Clicks.Value >= 3 then
CloneOverhead.Frame.ClickRank.Text = "Medium"
elseif Clicks.Value >= 2 then
CloneOverhead.Frame.ClickRank.Text = "Normally"
else
CloneOverhead.Frame.ClickRank.Text = "Starter"
end
end)
then you could use the Clicks value to index the corresponding rank:
Clicks:GetPropertyChangedSignal("Value"):Connect(
function()
CloneOverhead.Frame.ClickRank.Text = ClickRanks[Clicks.Value] or "Starter"
end
)
Lets say the player gets 1 click, what this does is it tries to find the index 1 in the table, but fails to do so, so it returns nil, and the or statement will check if the first variable supplied is not equal to nil or false and if it is it will return the second variable. Vica versa, if I have 5 clicks, I will be able to index the table because there is a value at table index 5 so the or statement will just return my corresponding rank
Thank you it works but I’m trying to turn the table to a ModuleScript how do I do it? I’m trying but it says ``
invalid argument #3 (string expected, got nil)```