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

How to use color3 in a gui with text?

Asked by
hokyboy 270 Moderation Voter
5 years ago
local InsertService = game:GetService("InsertService") 

script.Parent.MouseButton1Click:Connect(function()
    local ID = script.Parent.Parent.IdHolder.Text -- Get the id here
    local Model

    local success,err = pcall(function()
        Model = InsertService:LoadAsset(tonumber(ID))  -- Transforms text into a number
    end)

    if not success then -- If errors
        script.Parent.Parent.Display.Text = "Error Loading Map,Right Id?" 
        script.Parent.Parent.Display.TextColor3 = 255, 0, 0-- ERROR LINE
    else -- If not errors
        local NewModel = Model:GetChildren()[1] 
        NewModel.Parent = workspace 
        Model:Destroy()
        script.Parent.Parent.Display.Text = "Sucsess"
        script.Parent.Parent.Display.TextColor3 = 85, 255, 0 -- ERROR LINE
        wait(3)
        script.Parent.Parent.Display.Text = "Output"
        script.Parent.Parent.Display.TextColor3 = (Color3)255 255, 255) -- ERROR LINE
    end
end)

heh kinda forgot how to use color3 :/

2 answers

Log in to vote
1
Answered by 5 years ago
local InsertService = game:GetService("InsertService") 

script.Parent.MouseButton1Click:Connect(function()
    local ID = script.Parent.Parent.IdHolder.Text -- Get the id here
    local Model

    local success,err = pcall(function()
        Model = InsertService:LoadAsset(tonumber(ID))  -- Transforms text into a number
    end)

    if not success then -- If errors
        script.Parent.Parent.Display.Text = "Error Loading Map,Right Id?" 
        script.Parent.Parent.Display.TextColor3 = Color3.fromRGB(255, 0, 0)-- ERROR LINE
    else -- If not errors
        local NewModel = Model:GetChildren()[1] 
        NewModel.Parent = workspace 
        Model:Destroy()
        script.Parent.Parent.Display.Text = "Sucsess"
        script.Parent.Parent.Display.TextColor3 = Color3.fromRGB(85, 255, 0) -- ERROR LINE
        wait(3)
        script.Parent.Parent.Display.Text = "Output"
        script.Parent.Parent.Display.TextColor3 = Color3.fromRGB(255 255, 255) -- ERROR LINE
    end
end)

0
Or you can simply use Color3.new(255/255, 0/255, 0/255) but you'll have to devide them with the 255. AswormeDorijan111 531 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

You had to specify the color3 type, you have to put Color3.new after the = and in parentheses put the color code

local InsertService = game:GetService("InsertService") 

script.Parent.MouseButton1Click:Connect(function()
    local ID = script.Parent.Parent.IdHolder.Text -- Get the id here
    local Model

    local success,err = pcall(function()
        Model = InsertService:LoadAsset(tonumber(ID))  -- Transforms text into a number
    end)

    if not success then -- If errors
        script.Parent.Parent.Display.Text = "Error Loading Map,Right Id?" 
        script.Parent.Parent.Display.TextColor3 = Color3.new(255, 0, 0)-- ERROR LINE
    else -- If not errors
        local NewModel = Model:GetChildren()[1] 
        NewModel.Parent = workspace 
        Model:Destroy()
        script.Parent.Parent.Display.Text = "Sucsess"
        script.Parent.Parent.Display.TextColor3 = Color3.new(85, 255, 0) -- ERROR LINE
        wait(3)
        script.Parent.Parent.Display.Text = "Output"
        script.Parent.Parent.Display.TextColor3 = Color3.new(255 255, 255) -- ERROR LINE
    end
end)

not sure if new is capitalized

Answer this question