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

I'm new to scripting, how would I change a textlabels color and font by a script?

Asked by 6 years ago

Idk how to do this. I tried this:

script.Parent.MouseButton1Click:Connect(function)
game.StarterGui.ScreenGui.TextLabel.Color = "Black"
game.StarterGui.ScreenGui.TextLabel.Font = "Cartoon"

But that didn't work. Can someone please help me?

0
This will not work because the StarterGui only changes for the new incoming players. You need to get the player variable and then find the Gui that's parent is the player... BabyDevil285 9 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

AstronomicalDialect to change Gui's text or font by using scripts is by:

for changing the color do this:

game.StarterGui.ScreenGui.TextLabel.BackgroundColor3 = Color3.fromRGB(insert the color3 value here)

and if you want to change the font do this:

game.StarterGui.ScreenGui.TextLabel.TextFont = Enum.TextFont.Cartoon
0
It doesn't work like that; Also Roblox Lua will throw many errors at you BabyDevil285 9 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

Here is the answer:

First, you need to put a BoolValue in the ServerStorage (or anywhere) Then, Place a Part containing a ClickDetector. Next, you will have to write the script in a ServerScript inside the clickable part:

local Value = game.ServerStorage.Value
local function clicked() -- The function to exectue when clicked
    Value.Value = true
end

script.Parent.ClickDetector.MouseClick:connect(clicked)

After, you write this in a LocalScript that is placed inside StarterPlayerScripts:

local Value = game.ServerStorage.Value
Value.Changed:connect(function()
    _G.Gui.TextColor3 = Color3.fromRGB(0, 0, 0) -- (0, 0, 0) is black
    _G.Gui.Font = Enum.Font.Cartoon
end)

Lastly, because without this script it will throw an error, write this in a LocalScript inside the ScreenGui:

_G.Gui = script.Parent.TextLabel -- Global Variable

There ya have it ;)

It's a little complex because of the way Roblox Lua throws errors at you, but it's good to know how it works!

Also if the you do not click a part, but a Gui button then please comment "Wrong Click" for me to explain that side, which is way easier :D

Answer this question