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

Attempt to call a nil value error when making baseplate random color?

Asked by 3 years ago
Edited by raid6n 3 years ago

I am trying to make my Baseplate a random color. I put this script in the Baseplate:

local Random = math.random(0, 255)
local Baseplate = game.Workspace:WaitForChild(“Baseplate”)
Baseplate.Color = Color3.FromRGB(Random, Random, Random)

This outputs the following: Workspace.Baseplate.Script:3: attempt to call a nil value(EndOfLine) Stack Begin(EndOfLine) Script ‘Workspace.Baseplate.Script’, Line 3(EndOfLine) Stack End(EndOfLine)

Please help

1 answer

Log in to vote
2
Answered by
raid6n 2196 Moderation Voter Community Moderator
3 years ago

Few problems with your code, you used the wrong quotes and also I dont recommend naming your variables like Random, because it'd just error.

local RandomNumber = math.random(0, 255)
local Baseplate = game.Workspace:WaitForChild("Baseplate")
Baseplate.Color = Color3.fromRGB(RandomNumber, RandomNumber, RandomNumber)
Ad

Answer this question