Okay, so this may seem like a big script, but it's rather simple to understand. Basically the function alone changes the transparency of an ImageLabel.
Firstly The problem I am having is with the returncode. I am using return so that it won't play the other transparencies in the if statements, otherwise it won't work. I'm pretty sure there is a way around this but I will also be having 6 cards in the 1 function, as you can see it gets really long, plus the script won't continue after the 1st set of if's in Card1
Secondly As you can see this script is getting rather long, especially as I will be adding 6 other 'Cardx's which is why I am asking if there is a way to shorten it. Here's the code:
function openChest(Player)
if not debounce then
debounce = true
rotate(Lid, -Increment)
end
debounce = false
Item = chooseItem():Clone()
local chance = getChance(Item)
local ChestGui = Player.PlayerGui:WaitForChild("ChestGui")
local Card1 = ChestGui.Card1
if chance <= 10 then
Card1.Image = "http://www.roblox.com/asset/?id=" ..GoldCard
Card1.ImageTransparency = 0.8
wait()
Card1.ImageTransparency = 0.6
wait()
Card1.ImageTransparency = 0.4
wait()
Card1.ImageTransparency = 0.2
wait()
Card1.ImageTransparency = 0
Item.Parent = Player.Backpack
return;
end
if chance <= 50 then
Card1.Image = "http://www.roblox.com/asset/?id=" ..SilverCard
Card1.ImageTransparency = 0.8
wait()
Card1.ImageTransparency = 0.6
wait()
Card1.ImageTransparency = 0.4
wait()
Card1.ImageTransparency = 0.2
wait()
Card1.ImageTransparency = 0
Item.Parent = Player.Backpack
return;
end
if chance <= 100 then
Card1.Image = "http://www.roblox.com/asset/?id=" ..BronzeCard
Card1.ImageTransparency = 0.8
wait()
Card1.ImageTransparency = 0.6
wait()
Card1.ImageTransparency = 0.4
wait()
Card1.ImageTransparency = 0.2
wait()
Card1.ImageTransparency = 0
Item.Parent = Player.Backpack
return;
end
Item = chooseItem():Clone()
local chance = getChance(Item)
local ChestGui = Player.PlayerGui:WaitForChild("ChestGui")
local Card2 = ChestGui.Card2
if chance <= 10 then
Card2.Image = "http://www.roblox.com/asset/?id=" ..GoldCard
Card2.ImageTransparency = 0.8
wait()
Card2.ImageTransparency = 0.6
wait()
Card2.ImageTransparency = 0.4
wait()
Card2.ImageTransparency = 0.2
wait()
Card2.ImageTransparency = 0
Item.Parent = Player.Backpack
return;
end
if chance <= 50 then
Card2.Image = "http://www.roblox.com/asset/?id=" ..SilverCard
Card2.ImageTransparency = 0.8
wait()
Card2.ImageTransparency = 0.6
wait()
Card2.ImageTransparency = 0.4
wait()
Card2.ImageTransparency = 0.2
wait()
Card2.ImageTransparency = 0
Item.Parent = Player.Backpack
return;
end
if chance <= 100 then
Card2.Image = "http://www.roblox.com/asset/?id=" ..BronzeCard
Card2.ImageTransparency = 0.8
wait()
Card2.ImageTransparency = 0.6
wait()
Card2.ImageTransparency = 0.4
wait()
Card2.ImageTransparency = 0.2
wait()
Card2.ImageTransparency = 0
Item.Parent = Player.Backpack
return;
end
Chest.Lid.ClickSensor:Destroy()
end
All help is much appreciated.

3 comments
You can chain more elseifs indefinitely. So yes, you can use 3 ifs.
My bad, I'm not too good with loops though, which is why I'm asking for help on it.
http://wiki.roblox.com/index.php?title=Loops#For