Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i make particles emit from a player due to a click of a button?

Asked by 2 years ago

I want to make particles emit from my players torso from clicking the key "F" but a dont really know how to do that.

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

Hello,

to emit particles from an object, all you have to do is create a particle emitter and set it to be a child of that object. If you were to add particles to the torso of the player, you would just have to instance a particle emitter in a local script. It would look something like this:

local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local upperTorso = character:WaitForChild("UpperTorso")

local particlesEmitter = Instance.new("ParticleEmitter", upperTorso)

[Edit]:

You also need to implement user input, which is easily done with the help of the UserInputService. All you have to do is connect the "InputBegan" event to a function which will enable the particleEmitter:

local userInputService = game:GetService("UserInputService")
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local upperTorso = character:WaitForChild("UpperTorso")

local particlesEmitter = Instance.new("ParticleEmitter", upperTorso)
particlesEmitter.Enabled = false

userInputService.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.F then
        particlesEmitter.Enabled = true
    end
end)

Hope this helps.

Ad

Answer this question