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

Help with Color3.new and Pointlights?

Asked by 10 years ago

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

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

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) 
Ad
Log in to vote
1
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
10 years ago
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.

Answer this question