Gradual Transparency Increment of a Decal inside a Part

So, currently I’m making a Got Talent franchise game and I have to make a screen for it, which would have show’s logo and background which my make it attractive.

I’m facing issue with setting-up the script to make the two decals I have change their transparency gradually, for example, 0 to 0.2 so there is fade effect during the change of the decals.
image

Reference


Video credits to @the_jbroccoli

Any helps would be appreciated!

3 Likes

You can use math.sin along with RunService.Heartbeat to create a pulsing effect.

1 Like

It would be grateful if you could provide code, I am new to scripting, so yeah :slight_smile:

Try this, I have no idea if it works.
Modify the first 6 lines of course to your game.

local Sign = workspace["Small Screen L"]
local Decal1 = Sign.M1
local Decal2 = Sign.M2
local MinTransparency = 0
local MaxTransparency = 0.5
local FlashSpeed = 1

local Timer = 0
local Delta = (MaxTransparency - MinTransparency) / 2
local V = MinTransparency / 2 + MaxTransparency / 2
game:GetService("RunService").Heartbeat:Connect(function(Step)
Timer += Step * FlashSpeed
local Sine = math.sin(Timer * math.pi)
Decal1.Transparency = Sine * Delta + V
Decal2.Transparency = -Sine * Delta + V
end)

Put it in a Script in ServerScriptService

Didn’t works but thanks for trying.

Oops I tried to only set decal1, either way, what wasn’t working? Did just nothing happen at all? Any error messages?

Nothing just happened.
only30chars

You can just use tweens.

local tweenService = game:GetService("TweenService")

local decal = workspace.Part.Decal

local tweenInfo = TweenInfo.new(1)
local goal = {Transparency = 1}
local tween = tweenService:Create(decal, tweenInfo, goal)
tween:Play()
1 Like

I don’t really know how to script tweens, I found a solution, maybe I will post it here, if it works smooth.

Bro I tried the script and it was working? Idk what you mean

Did not work for me? I’ll try again if you say so.

It worked, there was a clash with other scripts :slight_smile:

local decal1 = script.Parent:FindFirstChild("M1")  
local decal2 = script.Parent:FindFirstChild("M2") 

local transitionDuration = 0.5  -- the duration of the transition (in seconds)
local interval = 0.009  -- the interval between transparency changes

local function transition(decal1, decal2)
	local transparency = 0
	local direction = interval / transitionDuration  -- the transparency change per second

	while transparency < 1 do
		decal1.Transparency = transparency
		decal2.Transparency = 1 - transparency
		wait(interval)
		transparency = transparency + direction
	end

	decal1.Transparency = 1  -- Ensure final transparency value is set accurately
	decal2.Transparency = 0
end

while true do
	-- Transition from Decal1 to Decal2
	transition(decal1, decal2)
	wait(transitionDuration)

	-- Transition from Decal2 to Decal1
	transition(decal2, decal1)
	wait(transitionDuration)
end

This code can also work. Just make sure the part color is set to something darker if your decal is the same and vice versa.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.