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

How to make it so particles show up on a player when button is pressed?

Asked by 6 years ago

I basically want my R15 player to have particles on their hands for 1.6 seconds. Here is the script (you don't need to add comments, I have some scripting knowledge of variables, parents, etc)

plr = game.Players.LocalPlayer
cooldown = 1
local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id=1541393089"
function onKeyPress(inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.Z and cooldown >0 then
                        -- particles appear on LeftHand and RightHand
        cooldown = 0
        local playAnim = plr.Character.Humanoid:LoadAnimation(anim)
        playAnim:Play()
        plr.Character.Humanoid.WalkSpeed = 40
        wait(1.6)
                         --particles are gone here
        plr.Character.Humanoid.WalkSpeed = 16
        wait(3)
        print("Explosion Dash")
        cooldown = 1
    end
end

game:GetService("UserInputService").InputBegan:connect(onKeyPress)

Please help me!

1 answer

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

Okay, I see you didn't even try to even make the particle emmiters. Just so you know, this community doesn't give answers for free, you need to try and learn.

Now, I'll give a few tips before I answer your question.

  • Use :Connect instead of :connect, this last one is deprecated and its functionality might be deleted anytime.
  • Now with cooldown variable, I see you only use 0 and 1 as its value, so you might want to use true and false, won't make any difference but your script will look nicer, just an opinion.

Now, I assume your script is a LocalScript due to UserInputService, which can only be accessed by client (if you don't know what I mean, then LocalScripts)

Now, I also assume you got your particles ready, if you got your particles done already then place them in ReplicatedStorage, and use this script:

plr = game:GetService("Players").LocalPlayer
cooldown = false
local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id=1541393089"

local particles = game:GetService("ReplicatedStorage").Particle --THIS IS WHAT THE SCRIPT WILL REFER AS THE PARTICLES YOU'RE GOING TO USE, CHANGE THIS IF YOUR PARTICLE'S NAME OR PARENT IS DIFFERENT.

function onKeyPress(inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.Z and cooldown ~= false then

        local CloneP1, CloneP2 = particles:Clone(), particles:Clone()
        CloneP1.Parent = plr.Character.RightHand; CloneP1.Enabled = true
        CloneP2.Parent = plr.Character.LeftHand; CloneP2.Enabled = true

        cooldown = true
        local playAnim = plr.Character.Humanoid:LoadAnimation(anim)
        playAnim:Play()
        plr.Character.Humanoid.WalkSpeed = 40
        wait(1.6)

        CloneP1:Destroy(); CloneP2:Destroy()

        plr.Character.Humanoid.WalkSpeed = 16
        wait(3)
        print("Explosion Dash")
        cooldown = false
    end
end

game:GetService("UserInputService").InputBegan:Connect(onKeyPress)

This script won't work with R6 unless you add some condicionals and stuff. Hope this helped!

NOTE: THIS IS NOT FE COMPATIBLE, for more information, see Experimental Mode and Remote Events and Functions

0
lol it dont even work there are no instances, and you were telling me to use them M8 u dont even use them myself. you just disabled the script by doing what you did stock458 51 — 6y
0
^ Did you really just copy paste the whole script without reading it? If you read the whole answer and code, you’ll see where the particles come from. User#20279 0 — 6y
Ad

Answer this question