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

Is there a way to have moving particle follow your mouse?

Asked by 8 years ago

I need help creating a script to put into a sword that whenever I press "Z" it will create red particles where my mouse is, and follow my mouse- I would also like for the particles to do damage. Particles need to be able to disappear upon me press Z again.

Any ideas? I'm not sure how to do any of this, so can someone direct me to a source of information I can use to help?

Or can someone help me figure out the basis so I can stem off of it?

1 answer

Log in to vote
1
Answered by 8 years ago

I won't do this for you, but I'll shoot you some ideas about going about this.

- Suggestion 1,

Use a Local Script inserted into some Service that gets replicated to the player, like StarterGui.


- Suggestion 2,

Now that we're using a Local Script, we can get the Local Player and the player's mouse. We would do this like so,

-- Local Script In StarterGui
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
Get's player, and player's mouse

- Suggestion 3,

Use user input service to detect the Z button being pressed.


- Suggestion 4,

Insert an invisible part that follows the mouse, and place the particles in the part.


- Suggestion 5,

Use mouse.Hit to get the CFrame of the mouse's world CFrame. This is very important. You would do the following to make a part where the mouse is in the world,

-- Local Script In StarterGui
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

local p = Instance.new("Part", game.Workspace)
p.CFrame = mouse.Hit

But this wouldn't really work if mouse.Hit is nil, and also because this isn't on a loop or event.

So Also,

Use a Mouse move event. Similar to so,

-- Local Script In StarterGui
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
mouse.Move:connect(function()
    if mouse.Hit ~= nil then
        local p = Instance.new("Part", game.Workspace)
        p.CFrame = mouse.Hit
    end
end)

Those are some of my ideas. I would provide an complete answer if I had more time. Later, if you're still having trouble, I could provide a better answer.

Good Luck!

If I did help, please don't forget to hit the accept button, it helps a lot. Thank you.
1
As an extension of the above, look at Mouse.Hit to get the position that the mouse is at, and if you insert a BodyPosition into the part and give it a maxForce of (math.huge,math.huge,math.huge), then just set the position to the Mouse.Hit value darkelementallord 686 — 8y
2
You could use the Enabled property of the particle effect to turn it on and off. darkelementallord 686 — 8y
1
Ah, that is something I forgot. I'm going to add that because that's very important. User#11440 120 — 8y
Ad

Answer this question