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

Changing the Color of a SurfaceLight using a script?

Asked by 8 years ago

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

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
8 years ago

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
0
That works. Thank you! Artavios 20 — 8y
Ad

Answer this question