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

Help with Color3.new and Pointlights?

Ok,so when ever this scripts spawns a firefly the firefly doesn't come the color how I want it (255, 203, 15) instead it comes out with some random color that's white,why?

local fireflyscript = script.FireflyScript
local debris = game.Debris
	while true do 
	local p=Instance.new("Part")
	p.Name="Firefly"
	p.formFactor="Custom"
	p.Friction=0
	p.Elasticity=0
	p.Size=Vector3.new(.1,.1,.1)
	p.CFrame=script.Parent.CFrame
	p.Transparency=1
	p.CanCollide=true
	p.TopSurface="Smooth"
	p.BottomSurface="Smooth"
	local sb=Instance.new("SelectionBox")
	sb.Color=BrickColor.new("Bright orange")
	sb.Adornee=p
	sb.Parent=p
	local bf=Instance.new("BodyVelocity")
	bf.maxForce=Vector3.new(1,1,1)*10^2
	bf.velocity=Vector3.new(math.random()-.5,1,math.random()-.5)*4
	bf.Parent=p
	local bf=Instance.new("BodyAngularVelocity")
	bf.maxTorque=Vector3.new(1,1,1)*10^2
	bf.angularvelocity=Vector3.new(math.random()-.5,math.random()-.5,math.random()-.5)*20
	bf.Parent=p
	local pl=Instance.new("PointLight")
	pl.Color= Color3.new(255,203,15)
	pl.Range=math.random(4,8)
	pl.Brightness=0.8
	pl.Parent=p
	local s=fireflyscript:clone()
	s.Disabled=false
	s.Parent=p
	debris:AddItem(p,math.random(20,30))
	p.Parent=game.Workspace
	wait(1)
	end
	

--This isn't mine I just edited it

2 answers

✓ Accepted answer

While the Properties tab shows Color3 parameters ranging from 0 to 255, the Color3.new constructor actually takes values from 0 to 1.

This means your color actually has to be defined as the fraction over 255, so it's usually written like:

Color3.new(255/255, 203/255, 15/255) 
local fireflyscript = script.FireflyScript
local debris = game.Debris
    while true do 
    local p=Instance.new("Part")
    p.Name="Firefly"
    p.formFactor="Custom"
    p.Friction=0
    p.Elasticity=0
    p.Size=Vector3.new(.1,.1,.1)
    p.CFrame=script.Parent.CFrame
    p.Transparency=1
    p.CanCollide=true
    p.TopSurface="Smooth"
    p.BottomSurface="Smooth"
    local sb=Instance.new("SelectionBox")
    sb.Color=BrickColor.new("Bright orange")
    sb.Adornee=p
    sb.Parent=p
    local bf=Instance.new("BodyVelocity")
    bf.maxForce=Vector3.new(1,1,1)*10^2
    bf.velocity=Vector3.new(math.random()-.5,1,math.random()-.5)*4
    bf.Parent=p
    local bf=Instance.new("BodyAngularVelocity")
    bf.maxTorque=Vector3.new(1,1,1)*10^2
    bf.angularvelocity=Vector3.new(math.random()-.5,math.random()-.5,math.random()-.5)*20
    bf.Parent=p
    local pl=Instance.new("PointLight")
    pl.Color= Color3.new(255/255,203/255,15/255) --You see, for some reason you can not just put the full numbers for Color3, but you have to divide these numbers by 255 to get Color3 to work properly.
    pl.Range=math.random(4,8)
    pl.Brightness=0.8
    pl.Parent=p
    local s=fireflyscript:clone()
    s.Disabled=false
    s.Parent=p
    debris:AddItem(p,math.random(20,30))
    p.Parent=game.Workspace
    wait(1)
    end


--This isn't mine I just edited it --Not what we want to hear typically.

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