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

How to make gui text change colors based on the text?

Asked by 2 years ago
Edited 2 years ago

I'm trying to make a spin system and im trying to make the text for each spin name a different color but i doesn't seem to work

Color script :

local tech = script.Parent.SpinnerText
if tech.Text == "Fire" then tech.TextColor3 = Color3.fromRGB(0, 84, 0)
end
if tech.Text == "Earth" then tech.TextColor3 = Color3.fromRGB(255,0,0)
end

if tech.Text == "Water" then tech.TextColor3 = Color3.fromRGB(255,0,0)
end

if tech.Text == "Air" then tech.TextColor3 = Color3.fromRGB(255,0,0)
end

if tech.Text == "Light" then tech.TextColor3  = Color3.fromRGB(255,0,0)
end

if tech.Text == "Gravity" then tech.TextColor3 = Color3.fromRGB(255,0,0)
end 
if tech.Text == "Void" then tech.TextColor3 = Color3.fromRGB(255,0,0)
end

if tech.Text ==  "Arcane" then tech.TextColor3 = Color3.fromRGB(255,0,0)
end

Spin Script:
local text = script.Parent.SpinnerText
local button = script.Parent.SpinnerButton
local spinnerEvent = game:GetService("ReplicatedStorage"):WaitForChild("SpinnerEvent")


local objects = {"Fire","Earth","Fire","Light","Fire", "Water","Fire","Earth","Water","Air","Earth","Fire","Void","Earth","Water","Earth","Light","Fire","Air","Earth","Fire","Gravity","Water", "Air","Earth","Air","Light","Water","Fire","Water","Air","Earth","Gravity","Fire", "Light","Earth","Water","Fire", "Gravity","Fire", "Arcane","Fire","Fire","Earth","Fire","Light","Fire", "Water","Fire","Earth","Water","Air","Earth","Fire","Void","Earth","Water","Earth","Light","Fire","Air","Earth","Fire","Gravity","Water", "Air","Earth","Air","Light","Water","Fire","Water","Air","Earth","Gravity","Fire", "Light","Earth","Water","Fire", "Gravity","Fire", "Arcane","Fire"}

--Fire total = 20
--Earth total = 16
--Water total = 14
--Air total = 10
--light total = 8
--GRavity total =6
--VOid Total = 2
--Arcane Total = 2


local start = math.random(1, #objects)

local function nextObject()
    if start == #objects then
        start = 1
    else
        start += 1
    end

    return objects[start]

end

button.MouseButton1Click:Connect(function()
    local waitTime = 0.1
    local spinCount = 50
    for i=spinCount, 0, -1 do
        text.Text = nextObject()

        if i <= 10 then
            waitTime += 0.1
        end
        wait(waitTime)
    end

    spinnerEvent:Fire(text.Text)
end)

Thanks in advance!

Answer this question