generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Issue with colour tweener

Previous Thread :: Next Thread 
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
02 Jan 2016 03:40 PM
This makes it change to the desired colour before becoming white. Any ideas?

function _G.tweenColor(colour, colour2, amount)
local col1 = Vector3.new(colour.r, colour.g, colour.b)
local col2 = Vector3.new(colour2.r, colour2.g, colour2.b)
return col1:lerp(col2, amount)
end

I input: for i = 0, 1, .01 do
local newcolor = _G.tweenColor(color, endcolor, i)
image.BackgroundColor3 = Color3.new(newcolor.X, newcolor.Y, newcolor.Z)
wait()
print(newcolor)
end
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
02 Jan 2016 03:43 PM
What's wrong with it? It becomes white when it shouldn't or? It looks fine, me assuming color and endcolor are constant throughout the loop.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
02 Jan 2016 03:45 PM
This particular issue can be solved using the solution to this particular issue which isn't vague at all and is definitely specified.
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
02 Jan 2016 03:46 PM
I input these values:
local endcolor = Color3.new(97, 95, 30)
local endcolor2 = Color3.new(0, 0, 0)

And get this:
24735, 24225, 7650
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
02 Jan 2016 03:49 PM
Color3.new takes numbers between 0 and 1, so in your case:
local endcolor = Color3.new(97/255, 95/255, 30/255)
Report Abuse
UnstableScript0 is not online. UnstableScript0
Joined: 21 Dec 2015
Total Posts: 1189
02 Jan 2016 04:07 PM
Don't use Vector3's, that is so much unneeded.

When I looked up "Ninjas" in Thesaurus.com, it said "Ninja's can't be found" Well played Ninjas, well played.
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
02 Jan 2016 04:59 PM
Thanks cnt!

How come, Unstable?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
02 Jan 2016 05:00 PM
You're creating an awful amount of objects, it's pretty hefty but it shouldn't really be much of a problem (for now).
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
02 Jan 2016 05:02 PM
Oh alright. What would you do?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
02 Jan 2016 05:05 PM
Well creating at least 1 new object every time is inevitable. I wouldn't create 3 Vector3s and a new Color3 every iteration, I'd probably just get the r g b values directly and only create a single new Color3 every iteration.
Report Abuse
UnstableScript0 is not online. UnstableScript0
Joined: 21 Dec 2015
Total Posts: 1189
02 Jan 2016 06:04 PM
Just make your own lerp function, because like cntkillme said, (and I would have said, had I been online, and was implying), you are creating lots of objects.

function lerp(a,b,t)
return a+t*(v-a)
end

If I remembered the formula correctly, that should work.

When I looked up "Ninjas" in Thesaurus.com, it said "Ninja's can't be found" Well played Ninjas, well played.
Report Abuse
UnstableScript0 is not online. UnstableScript0
Joined: 21 Dec 2015
Total Posts: 1189
02 Jan 2016 06:05 PM
Ah, made a mistake. Better change the v to a b if you want it to work :P

When I looked up "Ninjas" in Thesaurus.com, it said "Ninja's can't be found" Well played Ninjas, well played.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image