How to make a smooth effect?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I would like it so my signals change, but its in a smoother transition.

  2. What is the issue? Include screenshots / videos if possible!
    I am not able to make it smooth, I am not capable to do it. At the moment, it is just a colour change and it is not smooth: (below)
    Signal Testing

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried using a wait(0.3) but that doesnt do anything, its just a normal wait.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local part = script.Parent
local humanoid
local Sensor1 = script.Parent
local Signal1 = script.Parent.Parent

part.Touched:Connect(function(other)
    if other.Parent ~= nil then    
        humanoid = other.Parent:FindFirstChildOfClass("Humanoid")
        if humanoid then
            script.Parent.Touched:Connect(function()
                script.Parent.Parent.TopPart.SurfaceGui.TopLabel.ImageColor3 = Color3.fromRGB(15, 15, 15)
wait(0.3)
                script.Parent.Parent.BottomPart.SurfaceGui.BottomLabel.ImageColor3 = Color3.fromRGB(255, 0, 0)
            end)
        end

        if humanoid then
            humanoid.Died:Connect(function()
                part.Touched:Disconnect()
            end)
        end
    end
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

2 Likes

You could use TweenService.
Also consider using task.wait() instead of wait().

local part = script.Parent
local humanoid
local Sensor1 = script.Parent
local Signal1 = script.Parent.Parent
local TweenService = game:GetService("TweenService")

part.Touched:Connect(function(other)
    if other.Parent ~= nil then    
        humanoid = other.Parent:FindFirstChildOfClass("Humanoid")
        if humanoid then
            script.Parent.Touched:Connect(function()
                TweenService:Create(script.Parent.Parent.TopPart.SurfaceGui.TopLabel, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {ImageColor3 = Color3.fromRGB(15, 15, 15)})
                task.wait(0.3)
                TweenService:Create(script.Parent.Parent.TopPart.SurfaceGui.TopLabel, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {ImageColor3 = Color3.fromRGB(255, 0, 0)})
            end)
        end

        if humanoid then
            humanoid.Died:Connect(function()
                part.Touched:Disconnect()
            end)
        end
    end
end)

Hi. Thanks for your help, I received this error:

1 Like
local part = script.Parent
local humanoid
local Sensor1 = script.Parent
local Signal1 = script.Parent.Parent
local TweenService = game:GetService("TweenService")

part.Touched:Connect(function(other)
	if other.Parent ~= nil then
		humanoid = other.Parent:FindFirstChildOfClass("Humanoid")
		if humanoid then
			script.Parent.Touched:Connect(function()
				local offTween = TweenService:Create(
					script.Parent.Parent.TopPart.SurfaceGui.TopLabel,
					TweenInfo.new(
						.15,
						Enum.EasingStyle.Sine,
						Enum.EasingDirection.Out
					),
					{
						ImageColor = Color3.fromRGB(15, 15, 15)
					}
				)
				offTween:Play()
				task.wait(0.3)
				local onTween = TweenService:Create(
					script.Parent.Parent.BottomPart.SurfaceGui.BottomLabel,
					TweenInfo.new(
						.15,
						Enum.EasingStyle.Sine,
						Enum.EasingDirection.Out
					),
					{
						ImageColor = Color3.fromRGB(255, 0, 0)
					}
				)
			end)
		end

		if humanoid then
			humanoid.Died:Connect(function()
				part.Touched:Disconnect()
			end)
		end
	end
end)

Use TweenInfo to customize the duration and easing of the animation.

Strange, no error on my side.‏‏‎ ‎

The Answer is Interpolation, which is essentially what TweenService does, If you wanted to make a custom function, you can use the formula for Lerp, which is Lerp{a, b, t} = a + (b - a) * t, which is basically: Point A. Plus the Difference between Point B and Point A, muliplied by time. Which is applied from 0 to 1, if you wanted to turn this into a function, you can do this:

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

For Color Interpolation, you need to do this for every single color value of the Color, so one for Red which is R, Green which is G, and Blue which is B.

Am I supposed to get this error?

t

Heres my workspace:
image

My bad, replace ImageColor with ImageColor3

Hi. Thanks for your help so far, I received another error:

Hi all, I didn’t share a video with you, here you go:

External Media