# How to make a fade color due to the player position

Hey developers i want to know if someone can explain to me how to make this : https://media.discordapp.net/attachments/850158653905305610/1058195611905708082/Untitled_Game_-_Roblox_Studio_2022-12-29_20-30-03.mp4

Please 2 Likes

The Simplest way to to have a set of Parts Named after a specific set of numbers, and to have them tween that specific times.

You can then have a system where when you press a new option, you can cancel the Tween and and start the next transition.

The Color is slightly more complicated than that, you would need to create a ordered list of Colors you want the Color to Tween through, and then have them tween to all Parts using a for loop under a set time.

To set a speed, you would need to check what percentage the Bar is on the UI which would be the `current` amount divided by the `Full` amount, where you can then set the speed accordingly by maybe multiplying that value a certain amount.
If you wanted to, you have a value to be typed in where you can set the speed via typing in a number.

1 Like

But how can i get the player position and make the rgb color sync on the glowstick ?

It looks like the they are in some sort of sine wave

So I am going to guess the equation is something like

``````Light.brightness=(math.sin(Character.Position.Magnitude/5)+1)*10
``````

you can modify it but it is like (sine(`{distance from origin}`)+1)*halfmaxbrightness

for me to break it down sine is a wave pattern that repeats

distance from origin can be something like (playerposition-randomvector).Magnitude
the magnitude part is to get the distance from randomvector
the +1 is to make it from a range from -1 to 1 into 0 to 2
you can probably guess what halfmaxbrightness means

EDIT:I forgot to include runservice

use something like this script assuming it was put in starter character

``````Character=script.Parent
time=0
Runservice.renderstepped:Connect(function(dt)
time+=dt
Light.Brightness=(math.sin(Character.Position.magnitude)+1)*10
end)
``````

I made this script on my phone but using runservice you can loop through every player and apply it to their character if they have one.

1 Like