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

How would I put particle effects on a player when a player presseda keyboard button?

Asked by 4 years ago

So I'm trying to put particles effect in a player after pressing the later "F" however, I tried all the scripts that might work but it didn't... can anyone please help?

1 answer

Log in to vote
0
Answered by
crueluu 169
4 years ago
Edited 4 years ago

So, First You Need To Insert A local script in StarterPlayer.StarterCharacterScripts then we have to know what U.I.S Is ..So U.I.S Basically Stands For UserInputService, Its Name Is Really Self Explanatory It Detects If A Player Has Pressed A certain Button(Input) so we'd have to first Get The Player Then detect if the player is Pressing Something But First Lets Get The UIS Service:

1local player = game.Players.LocalPlayer
2 
3local uis = game:GetService("UserInputService"

After We Got The Service It Should Be Easier To Detect What The Local Player Has Pressed Since We Dont Need To Write A Whole Line But Instead "uis" Because Thats What We Refrenced It To, So Now We Detect If A Player Has Pressed A KB Button :

1local player = game.Players.LocalPlayer
2 
3local uis = game:GetService("UserInputService"
4 
5  uis.InputBegan:Connect(function(input)
6 
7end)

This Will Only Detect If A Player Presses ANY Button Which Is Not What We Want So.. We'll Have to detect WHICH button Has Been Pressed:

1local player = game.Players.LocalPlayer
2 
3local uis = game:GetService("UserInputService"
4 
5  uis.InputBegan:Connect(function(input)
6 if input.KeyCode == Enum.KeyCode.F then
7print("ButtonF Has Been Pressed")
8  end
9end)

This Should Print "ButtonF Has Been Pressed" Since The Player Pressed "F" Now After That We Can Tell The Script Finally What To Do When "F" is Pressed, Which In Your Case You Want It To Add A Particle Effect So We Will Use "Instance.new" Which Adds An Instance:

01local player = game.Players.LocalPlayer
02 
03local uis = game:GetService("UserInputService"
04 
05  uis.InputBegan:Connect(function(input)
06 if input.KeyCode == Enum.KeyCode.F then
07print("ButtonF Has Been Pressed")
08      local Effect = Instance.new("Fire") --replace this with the particle you want/effect
09  end
10end)

Then Will Set The Parent To The Local Players Character:

01local player = game.Players.LocalPlayer
02 
03local uis = game:GetService("UserInputService"
04 
05  uis.InputBegan:Connect(function(input)
06 if input.KeyCode == Enum.KeyCode.F then
07print("ButtonF Has Been Pressed")
08     local Effect = Instance.new("Fire") --replace this with the particle you want/effect
09Effect.Parent = player.Character.Head
10 
11  end
12end)

This Should Be Working Properly You Can Just Change The Particele To Whatever You Want, it would like this : https://gyazo.com/ebec1261b579dd78281065aab5215838, Edit: Accept This As An Answer If It Worked.

0
Don't forget your gameProcessedEvent XviperIink 428 — 4y
0
Hmm.. Yup I Forgot But It Still Worked. crueluu 169 — 4y
Ad

Answer this question