Hello, Im beginner scripter and somehow I see a lot of game in Roblox that when they shoot skill, magic or some projectile there are effect while projectile is launch. something like picture below if u can’t imagine.
Expanding off of what @TheBrainy06 said, Roblox actually has a pretty good tutorials with their Onboarding program. The two tutorials you may need are as listed below:
The first one is just if you need to know how to use the tool object. The second one includes all the steps that @TheBrainy06 mentioned and provides a step-step explanation of what it’s doing and why.
Note: the tutorial “Detecting Player Input” uses ContextActionService with a tool, but you do not need to have a tool to use it if you don’t want to. All it really does is bind one or more keys to a specific function when pressed or unpressed.
Raycasting is the best method. With raycasting all you have to do is something like this:
local projectile = workspace.Projectile -- example part
local distance = 3
local frame = projectile.CFrame
local result = workspace:Raycast(frame.Position, frame.LookVector * distance)
if result then
-- do code for whatever you want to do on a collision.
else
projectile.CFrame += frame.LookVector*distance -- move the projectile forward
end
One thing I should mention, usually creating and destroying instances as fast as some games do means it will create some lag. To avoid this games usually implement a part-cacheing system so that they can reuse old projectile parts. One of the best modules out there for this (that I know of) is PartCache.
The best method for projectiles is to anchor them and then CFrame them along a path.