Creating a cash animation

I want to try creating a cash animation when a player earns cash, so like a bunch of icons are created, and they kinda spray out like a fountain, or something a long those lines. What I’ve got at the moment is pretty pathetic tho

local TweenService = game:GetService('TweenService')

local function CreateCash()
	local Cash = Instance.new('ImageLabel')
	Cash.AnchorPoint = Vector2.new(0.5, 0)
	Cash.BackgroundTransparency = 1
	Cash.Position = UDim2.new(0.5, 0, 1, 0)
	Cash.Size = UDim2.new(0.9, 0, 0.9, 0)
	Cash.Image = 'http://www.roblox.com/asset/?id=2283894564'
	Cash.ScaleType = Enum.ScaleType.Fit
	
	local AspectRatio = Instance.new('UIAspectRatioConstraint')
	
	AspectRatio.Parent = Cash
	
	return Cash
end

return function(parent)
	for i = 1, 20 do
		local Cash = CreateCash()
		Cash.Parent = parent
		
		local Move = TweenService:Create(
			Cash, 
			TweenInfo.new(0.5), 
			{Position = UDim2.new(math.random(10, 100) / 100, 0, math.random(10, 100) / 100, 0)}
		)
		Move:Play()
	end
end

ezgif.com-video-to-gif (1)

1 Like

You could try getting the Screen Size and then use that inside of your math.random(), that way they can appear across the entire screen. After a couple more seconds you could tween them to the total cash the player has on the top right and then destroy them.
GuiBase2d.AbsoluteSize is what you can use to get the screen size, but there are other methods as well.

1 Like

I’m not trying to cover the entire players screen. I just want a small animation over near the top right

you can still do it the way @SimplyData told ya.

Just make them spread in the top left like how you already made it and then tween each one to the top right.

Not really what I’m after tho.

More updated version, but it’s still eh
robloxapp-20200222-2043231 (1)

Maybe try tweening them so they move over the cash icon?

1 Like