How to apply effect to the place of the user interface where the click was

i wanna achieve that where player clicked in the ui interface, will play effect of this click.
i need some hint or help how can i do this.

2 Likes

I’m assuming you want to play a “click” sound when a Player clicks on a certain UI object.

If you’re using TextButtons/ImageButtons, you can use MouseButton1Up to detect when the Player releases their left mouse button from the button.

You can use UserInputService.InputBegan to detect universal touch-taps and left-mouse button clicks. The event will provide your connected function with an InputObject, which describes the context of the input. You will first use it to isolate the aforementioned input. Afterwards, you can access its “Position” property for information about where on the screen (in offset/pixels) the touch-tap/click occurred. The top-bar inset is accounted for in this value

i want to play effect like particle emitter do

i know i can detect when play clicked issue i dont know how apply effect to click

You’d have a particle inside of the part, you just have to change the event and stuff.

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

local particlePart = game.ReplicatedStorage:WaitForChild("PP")

mouse.Button1Down:Connect(function()
	local np = particlePart:Clone()
        np.CFrame = mouse.Hit
        np.Parent = workspace
end)

My previous message is assuming you’re working in 2D space with GUIs. Use the information I gave you to learn where on the screen the touch-tap/click occurred. You can place the VFX GUI you want to appear at that position, and proceed with any animations, property changes, and associated SFX from there

Ah, I see.

Like I’ve mentioned, you can use MouseButton1Up to check when the Player has fully clicked on a button. However, if you want 2D particles to play whenever the Player clicks on a button, you’ll have to script a separate system for that. I’ll recommend you searching up resources on the DevForum or on YouTube to see how you can go around this.

Using .Activated would better, it checks if the click started and ended on the button.

script work yes but only in 3d world i want to get it work with ui elements

Then I suggest you investigate my advice, @ScriptSQL

then who will be parent of effect?

The effect does not need to be attached to any one GUI—it will exist in its own ScreenGui

You wan’t to have a particle on the screen? Like its like a particle emiter but in a UI?
You’d need to make a function and get the mouse position on the screen.

local userInputService = game:GetService("UserInputService")
local tweenService = game:GetService("TweenService")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

-- UI container where effects will be added (make sure it's inside a ScreenGui)
local ui = script.Parent  -- Parent should be a ScreenGui

-- Function to create a click effect
local function createClickEffect(x, y)
	local effect = Instance.new("ImageLabel")  -- You can use Frame or ImageLabel
	effect.Size = UDim2.new(0, 50, 0, 50)  -- Size of effect
	effect.AnchorPoint = Vector2.new(0.5, 0.5)
	effect.Position = UDim2.new(0, x, 0, y)
	effect.Image = "rbxassetid://YOUR_EFFECT_IMAGE_ID"  -- Replace with your effect image
	effect.BackgroundTransparency = 1
	effect.Parent = ui
	effect.ZIndex = 10  -- Ensure it appears on top
	task.wait(10)
	effect:Destroy()
end

-- Detect any mouse click
userInputService.InputBegan:Connect(function(input, gameProcessed)
	if input.UserInputType == Enum.UserInputType.MouseButton1 and not gameProcessed then
		createClickEffect(mouse.X, mouse.Y)
	end
end)
1 Like

There is no need to access the user’s mouse. The InputObject provided to you already contains information about the on-screen position of the touch-tap/click. It accounts for the top-bar inset too

its working well one problem can it be like ParticleEmitter? or its only can do images?

More work is required to emulate a particle emitter in two dimensions. To my knowledge, no built-in solution exists for this. HelpSupport01’s reply contains a link to a video that might point you in the right direction

There is no particle emitter UI element, you would need to make your on thing to animate it/make it like a particle emitter.

Also I just asked gpt for that it’s not a good script but you can learn on it.

i have last question if i click TextButton effect dont play how fix this? @Eri_oxo

You can remove the “not gameProcessed” in the if statement.

1 Like