Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Attempt to call a nil value? (CLOSED)

So i want my text to change background color when clicked, but instead it throws an error in the question name.

My code:

local ekran = script.Parent.Parent.Parent.Ekran.SurfaceGui.TextLabel
local cd = script.Parent.ClickDetector

cd.MouseClick:Connect(function()
	ekran.BackgroundColor3 = Color3.New("Really red")
	ekran.Text = "STOP"
end)

Edit: someone answered the question in comments. thanks!

5 comments

0

which line?

0

5

0

5

1

Color3.fromRGB(255,0,0). LocalScripts cannot be used to operate a ClickDetector.

0

But it is a normal script

2 answers

The problem is in Color3.New, it is new, not New, the 'n' is not capital.

so: local ekran = script.Parent.Parent.Parent.Ekran.SurfaceGui.TextLabel local cd = script.Parent.ClickDetector

cd.MouseClick:Connect(function()
    ekran.BackgroundColor3 = Color3.new(255,0,0)
    ekran.Text = "STOP"
end)

5 comments

0

Also, you'd have to use Color3.fromRGB.

0

it doesnt change color

0

Maybe you have set background transparency to 1. Check for little things, they may be the reason.

0

background transparency to 0 for it to show up ._.

0

it is on 0

A color3 cannot be made from a BrickColor, not that I know of, so try opening the properties panel, selecting the BackgroundColor3 and making a red color. Then, copy and paste the color code from there into the ekran.BackgroundColor3 = Color3.New("Really red"), replacing the string with the three color numbers. Then set the BackgroundColor3 back into what it was from the properties.

2 comments

0

it doesn't change color

0

oof,

This discussion is preserved as it was. New answers, comments, and votes are closed.