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

How to enable ParticleEmitter when jumping?

Asked by 7 years ago

Hey! So I am creating a game on Roblox called Sonic Brisk and just like any Sonic game, the character is supposed to turn into a ball when they jump. Now, the way I'm recreating this effect is by using Particle Emitters. So, the idea is that when the character jumps, the Particle Emmiter (which will be welded to the Torso or HumanoidRootPart) will be enabled and you'll see the spinning spike particles. The way I thought of doing this would be to make a script that will clone the part (with the Particle Emitter as it's child) onto the HumanoidRootPart or Torso and then Enable the Particle Emmiter when the player jumps. Does anyone have any idea how this could be accomplished?

1 answer

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

Added some fixes to the script.

-- First off, put the particle emitter in Server-storage.
-- Then Change the "Enabled" Value to "false".
-- change everything necessary in the script.
-- Put the script in Server-Script-Service.
-- And that's it!

game.Players.PlayerAdded:Connect(function(player)
    local va = Instance.new("StringValue")
    local Val = va.Value
    Val = player.Name
    game.ServerStorage.Particle:Clone().Parent = game.Workspace.Val.Torso -- Change "Particle", to the name of it.
    game.Workspace.Val.Humanoid.Jump = false
    function onKeyPress(inputObject, gameProcessedEvent)
        if inputObject.KeyCode == Enum.KeyCode.Space then
            game.Workspace.Val.Humanoid.Jump = true
            wait(1)
            game.Workspace.Val.Humanoid.Jump = false
        end
    end
    while wait() do -- inf loop
        wait(0.1)
        if game.Workspace.Val.Humanoid.Jump == true then
            local spin = Instance.new("BodyGyro")
            spin.CFrame = CFrame.fromEulerAnglesXYZ(0, -50, 0)
            game.Workspace.Val.Torso.Particle.Enabled = true -- Change "Particle", to the name of it.
            wait(1)
            game.Workspace.Val.Torso.Particle.Enabled = false -- Change "Particle", to the name of it.
        end
    end
end)

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

Answer this question