Creating a "Pulse" Effect through tweening

To get to the point I’m creating this GUI that has multiple effects in it and one of them I want to be a “Pulse” effect for example - : NIUmjdedSF

I’ve figured out a way to actually do it but it isn’t very workable. Basically what I do is I create a duplicate of the text (or whatever I’m trying to tween) and then :

and I’m looking for a way where it’s easy to manage and I don’t have to create an entire new script for it (it intervenes with the main script and messes it up)

I’ve asked the actual owner who created this and he said to not duplicate it and just tween it but I’m not sure how I can start.

Any tips?

1 Like

Is the script you posted not working as intended? Your code looks fine to me except that you would prolly need to delete the pulse clones after the tween is finished. Or do you want like a function that you can pass a gui object to and it pulses it?

Like

Pulse(Bio)
Pulse(Render)
-- etc

I think I’m willing to remove the clone without a problem but I’m not sure if it’ll fix the main script problem. Basically what happens when I don’t make a coroutine script;
image

all it does is loop it and doesn’t run code that is past that point .

What’s the issue with using a coroutine? Do you want multiple text containers to have the pulse effect at the same time?

Yea, multiple text labels & image labels will be running it at the same time

You could make a pulse function in a module script and then require the module script in your main script and just call module.pulse(textLabel) (or however you define the function). You should also post your code as text so people could edit it for you easier

Sure thing, I removed the clone & the coroutine script now it isn’t looping

local Bio = script.Parent.Admin.Menu.Inner.Tiles.Inner.Template2.Text.TextLabel

local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)


local function pulse()
	

	local tweenFade = TweenService:Create(Bio, tweenInfo, {TextTransparency = 1})

	Bio:TweenSize(UDim2.new(1, 8, 4, 4), Enum.EasingDirection.In, Enum.EasingStyle.Quint, 1)
	tweenFade:Play()
		
	local tweenFade = TweenService:Create(Bio, tweenInfo, {TextTransparency = 0})


end


while wait(1.8) do
	pulse()
	end;

tips?

Your module script could look something like this:

local PulseEffect = {}

local TweenService = game:GetService'TweenService'
local RunService = game:GetService'RunService'

local PulsingObjects = {}
local Info = TweenInfo.new(0.35, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)

local function Pulse(GuiObject)
	local Clone = GuiObject:Clone()
	Clone.Parent = GuiObject.Parent
	
	local Tween = TweenService:Create(Clone, Info, {
		TextTransparency = 1,
		Size = UDim2.new(GuiObject.Size.X.Scale * 1.5, 0, GuiObject.Size.Y.Scale * 1.5, 0)
	})
	Tween:Play()
	-- delete the clone after tween is done
	Tween.Completed:Connect(function(PlaybackState)
		Clone:Destroy()
	end)
end

function PulseEffect.StartPulse(GuiObject)
	table.insert(PulsingObjects, GuiObject)
end

function PulseEffect.StopPulse(GuiObject)
	local Index = table.find(PulsingObjects, GuiObject)
	if Index then
		table.remove(PulsingObjects, Index)
	end
end

-- Runs every 1.5 seconds
local LastPulse = 0
RunService.RenderStepped:Connect(function()
	if os.clock() - LastPulse < 1.5 then return end
	LastPulse = os.clock()

	for i, GuiObject in ipairs(PulsingObjects) do
		Pulse(GuiObject)
	end
end)

return PulseEffect

In your main script, just require the module and do module.StartPulse(textLabel). You’re probably gonna have to mess around with this line

Size = UDim2.new(GuiObject.Size.X.Scale * 1.5, 0, GuiObject.Size.Y.Scale * 1.5, 0)

because text scaling and wrapping in roblox is annoying so it might move wrapped text around, etc. Just try tweaking the new scale multiplier to whatever fits.

If you want the pulse to have a shorter delay before running again, make the 1.5 in the RenderStepped connection smaller, and if you want the tween to play faster change the 0.35 in the TweenInfo.

Here is my gui setup for the example:
image

LocalScript:

local TextLabel = script.Parent.TextLabel

local Pulse = require(script.PulseEffect)
local StartPulse, StopPulse = Pulse.StartPulse, Pulse.StopPulse

-- get the 3 textlabels and apply pulse to them
for i, v in pairs(script.Parent:GetChildren()) do
	if v:IsA'TextLabel' then
		StartPulse(v)
	end
end

The text resizing looks choppy because that’s the way roblox handles TextScaled. You could probably use TextContainer.AutomaticSize or something but I’ve never messed with that.
You could also maybe try turning off TextScaled and just tween the TextSize.

4 Likes

One more question,

Is there a way to change the angel the pulse where it’s coming from?
ex:

mine goes up instead of center
I’ve messed around with the

Size = UDim2.new(GuiObject.Size.X.Scale * 1.5, 0, GuiObject.Size.Y.Scale * 1.5, 0)

and nothing has changed with size etc.

Text scaling is off and everything.

That’s probably because of the label’s AnchorPoint. You can either set it to 0.5, 0.5 or make the tween account for the anchor point. Might also be AutomaticSize maybe.

My label’s properties look like this

image

So atm I’m trying to implement this into an image label.
I’ve simplified the script a little bit (lmk if this is good to do or not);

and all of it hooks up in here; image !

would an image label also work with anchor points? I’ve tried multiple ways and it doesn’t seem wanna work here’s what it does;

I want it to tween just like your example with the textlabels.

Is your image label sized with pixel offset? Cuz the tween goal uses scale

What do you mean by pixel offset?

Your image label size is UDim2.new(0, x, 0, y) but the tween goal uses UDim2.new(x, 0, y, 0).

In the pulse module, try changing GuiObject.Size.X.Scale * 1.5 to GuiObject.Size.X.Offset * 1.5, and the same for the Y (and also rearranging the coordinates properly btw)

UDim2.new(0, GuiObject.Size.X.Offset * 1.5, 0, GuiObject.Size.Y.Offset * 1.5)

The size of the imagelabel?
image

and I’ve changed back to the 1.5 in the pulse effect;

You need GuiObject.Size.X.Offset not Scale cuz scale is 0 since you used offset for the size

What do you mean by “GuiObject.Size.X.Offset”
like the X Y set? image

They mean you need to replace GuiObject.Size.X.Scale to GuiObject.Size.X.Offset (same with Y) in the pulse code