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

How to create a LightPart in the Workspace?

In the Roblox Wiki tutorial for learning to script, I tried to make a streetlight using coding. They only said: "Make sure the part we want to illuminate is named LightPart. This part should have the neon material so it appears to glow. Also insert a PointLight into the part so that it emits light on the parts around it. Feel free to play with the Color, Brightness, and Range of the PointLight so it creates the effect you want."Thus, I tried to create the light like if it was a part:

Instance.new("LightPart", Workspace) but it said that we could not create it.

The confusing part is when I was able to create a PointLight:

Instance.new("PointLight", Workspace)

2 answers

I think they just mean the .Name property of a normal part. There is no such thing as a 'LightPart', the reason it's going to be called this is just so it's got a name you would recognise when you come back to look at the parts in Workspace which can be helpful when you have several hundred or thousand. So the code you're looking for is this:

Part = Instance.new("Part",game.Workspace)
Part.Name = "LightPart"
Part.Material = "Neon"
Instance.new("PointLight",Part)

The 1st parameter is the object type/class, the second it optional as shown by the [] in the API which adds the new instance as a child for the given object. From the tutorial you are asked to create an object PointLight

The parent of this PointLight in a Part shown here

The final code

local newPart = Instance.new("Part", Workspace)  -- create a new part an put it in the workspace
newPart .Name = "newPart"  -- the name of this object

local newPointLight = Instance.new("PointLight", newPart)  -- create a new PointLight and adds it to the new part as a child e.g. workspace.newPart.newPointLight 
newPointLight .Name = "newPointLight"

Hope this helps

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