Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I create a spin function using a table?

Asked by
vesh19 0
5 years ago
Edited 5 years ago
local BendingInfo = {
    ["Fire"] = {Image = 180616021;
        TintColor = Color3.fromRGB(167, 0, 2)
    };
    ["Water"] = {Image = 180614881;
        TintColor = Color3.fromRGB(0, 76, 255)
    };
    ["Air"] = {Image = 180610038;
        TintColor = Color3.fromRGB(0, 255, 255)
    };
    ["Earth"] = {Image = 180617687;
        TintColor = Color3.fromRGB(0, 170, 0)
    };
}

local Gui = script.Parent.Parent

local MainFrame = Gui.MainFrame

local SpinButton = MainFrame.SpinButton

local Preview = MainFrame.Preview

local function RandomElement (num)

end

local OnSpin = function(Player)
    SpinButton.Visible = false

end

SpinButton.MouseButton1Click:Connect(OnSpin)

As you can see, I'm trying to make a spin for selecting which bend the player will acquire.

I don't have enough knowledge to know how to pick out the Image and TintColor to set the GuiButton's tint and setting the Preview's image id to the Image in the table. My main goal is to make a function to have it randomized and call it in the OnSpin function.

I tried using a loop for the table but I couldn't get it figured out.

Help will be appreciated, thanks!

Answer this question