Trying to emulate Raindrop Splashes on a Part's Surface

Now, I understand that I can easily use a ParticleEmitter to gain this sort of effect. But it’s not the intended effect I’m going for.

For ParticleEmitters, the image is constantly faced towards the Client’s camera at all times, and I don’t want that. So I’m relying on the production of ImageLabels being constantly created in a loop.

local asset = "http://www.roblox.com/asset/?id=3060979090"

local function Splash()
	local imagelabel = Instance.new("ImageLabel")
	imagelabel.Image = asset
	imagelabel.BackgroundTransparency = 1
	imagelabel.ImageTransparency = .5
	imagelabel.ImageColor3 = Color3.fromRGB(255,228,84)
	local randomSize = math.random(1,3)
	
    -- Determines the size of the image
	if randomSize == 1 then
		imagelabel.Size = UDim2.new(0.015,0,0.015,0)
	elseif randomSize == 2 then
		imagelabel.Size = UDim2.new(0.03,0,0.03,0)
	elseif randomSize == 3 then
		imagelabel.Size = UDim2.new(0.05,0,0.05,0)
	end
	
    -- Problem here
	imagelabel.Position = UDim2.new(math.random(0.21,0.35),0,math.random(0.11,0.25),0)
	imagelabel.Parent = script.Parent
	
	for i = 50,1,-1 do
		wait(.1)
		imagelabel.ImageTransparency = imagelabel.ImageTransparency + .1
	end
	
	imagelabel:Destroy()
end

while true do
	wait(.1)
	Splash()
end

I know this is probably really bad for performance issues, and I might get shredded for that, but I did identify the problem which was this line:

imagelabel.Position = UDim2.new(math.random(0.21,0.35),0,math.random(0.11,0.25),0)

Every single time, this line tries to generate a random position, the ImageLabel’s position is always at the {0,0,0,0} origin. Why?

Also, the loop at the very bottom of the script is yielding for the function to finish before playing the function again. (So it would only generate one splash, wait for it to finish, then generate another one.) How can I get around that?

Sorry, I know this is a lot, (and most likely impractical,) I’m just having a difficult time trying to get around this.

math.random() can’t random decimal so you will need to do something like thís

imagelabel.Position = UDim2.new(math.random(21,35)/100, 0, math.random(11,25)/100 ,0)

Even with that line added, it still positions the ImageLabel at the {0,0,0,0} origin.

To provide more clarity, this is ran on a local script within the SurfaceGui. I have also tried switching this to a server script, but no such luck.

I think a good way to do this might be through Beams. With beams it’s entirely possible to achieve what you are trying to achieve, it just won’t be the prettiest thing in the world I suppose.

For example, you can animate the raindrop falling with a Beam and calculate the time of the hit using a little math. Once the drop hits, you can make a splash effect by creating another small group of Beams. This is a sort of cartoony way of creating raindrop effects, but, I think it’s entirely possible to make it look good in most contexts.

2 Likes