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:

local player = game.Players.LocalPlayer

local 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 :

local player = game.Players.LocalPlayer

local uis = game:GetService("UserInputService")  

  uis.InputBegan:Connect(function(input)

end)

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:

local player = game.Players.LocalPlayer

local uis = game:GetService("UserInputService")  

  uis.InputBegan:Connect(function(input)
 if input.KeyCode == Enum.KeyCode.F then
print("ButtonF Has Been Pressed")
  end
end)

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:

local player = game.Players.LocalPlayer

local uis = game:GetService("UserInputService")  

  uis.InputBegan:Connect(function(input)
 if input.KeyCode == Enum.KeyCode.F then
print("ButtonF Has Been Pressed")
      local Effect = Instance.new("Fire") --replace this with the particle you want/effect
  end
end)

Then Will Set The Parent To The Local Players Character:

local player = game.Players.LocalPlayer

local uis = game:GetService("UserInputService")  

  uis.InputBegan:Connect(function(input)
 if input.KeyCode == Enum.KeyCode.F then
print("ButtonF Has Been Pressed")
     local Effect = Instance.new("Fire") --replace this with the particle you want/effect
Effect.Parent = player.Character.Head 

  end
end)

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