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

Changing the Color of a SurfaceLight using a script?

This is my current script. I want to make it so the SurfaceLight will be colored 255, 0, 0, or Really red.

game.Workspace.Light.Reflectance = 0.4
game.Workspace.Light.BrickColor = BrickColor.new("Really red")
game.Workspace.Light.Anchored = true

Instance.new("SurfaceLight", game.Workspace.Light)

game.Workspace.Light.SurfaceLight.Brightness = 4
game.Workspace.Light.SurfaceLight.Angle = 90
game.Workspace.Light.SurfaceLight.Face = "Top"
game.Workspace.Light.SurfaceLight.Range = 16

1 answer

✓ Accepted answer

Essentials

You almost have it, to accomplish what you're trying to do you just need to add one more thing;

Change the Color Property of the newly created SurfaceLight.


Suggestions

Other than what I stated above, I highly suggest you explore more usage of variables. To dumb it down, variables are basically little holders for data. You can assign a variable to any datatype you want.

So, in your case, I would suggest making 2 variables.

  • 1) Define a variable for workspace.Light

  • 2) Define a variable for the newly created SurfaceLight.


Code

--Define a variable for the light
local part = workspace.Light

--Change the Properties by indexing the variable
part.Reflectance = .4
part.BrickColor = BrickColor.new("Really red")
part.Anchored = true

--Define a variable for the SurfaceLight
local light = Instance.new("SurfaceLight",light)

--Manipulate the 'Color' Property to display red
light.Color = Color3.new(1,0,0)
light.Brightness = 4
light.Angle = 90
light.Face = "Top"
light.Range = 16

1 comment

0

That works. Thank you!

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