Getting the position of a part with velocity in the next second

hey devforumers!! today i wanted to make a silly particle effect that kiind of looks like it points to the direction you’re going to (the particle is gonna be played after a player is flinged). i’d rather not use lookvector because then it would point in a completely different direction if you use shiftlock or something. anyway, here’s what ive tried.
(for context, objecttoparticle here is a character’s torso.)

for i = 0, 10, 1 do
	task.spawn(function()
		local newparticol = Instance.new("Part")
		newparticol.Size = size
		newparticol.CanCollide = false
		newparticol.CanQuery = false
		newparticol.CanTouch = false
		newparticol.Massless = true
		newparticol.Anchored = true
		newparticol.Color = color
		newparticol.Name = "particle"
		newparticol.Transparency = .8
		newparticol.TopSurface = Enum.SurfaceType.Smooth
		newparticol.BottomSurface = Enum.SurfaceType.Smooth
		newparticol.Shape = Enum.PartType.Ball
		newparticol.CFrame = objecttoparticle.CFrame
		newparticol.Parent = workspace
		local doingit = true
		task.spawn(function()
			task.wait(4.2)
			doingit = false
		end)
		while doingit do
                        -- this next line is the one im struggling with. ive been trying to do it in... quite a lot of different ways. please help me with this. the most important thing here is the lookat(), just ignore all the different stuff
			local cframe1 = CFrame.lookAt(objecttoparticle.Position, objecttoparticle.Position + (((objecttoparticle.Position + objecttoparticle.AssemblyLinearVelocity).Unit) - objecttoparticle.Position)) * CFrame.Angles(0, math.rad(i * 36), 0) * CFrame.new(0, 2.5, 5)
			local propersnow = {["CFrame"] = cframe1}
			tweenserv:Create(newparticol, TweenInfo.new(.05, Enum.EasingStyle.Cubic), propersnow):Play()
			task.wait(.05)
		end
	end)
	task.wait(.02)
end

-- also for that one cframe.lookat() line i tried quite a bit of different stuff, like (objecttoparticle.Position + objecttoparticle.Velocity) buut it still didnt work

yeah devforumers i tried checking other posts but i didnt find anything there besides some weird usage of .magnitude which i still dont understand to be honest. also if you didnt really understand what i meant by “making the particle look like it points to the direction the player is going” i just want it to be like theres a ring that looks perpendicular to the direction of the torso (i know i didnt clear up ANY confusion but i hope you get the general idea)

writing this was really hard and im so sorry for the mess you had to read… if you want, i could illustrate the way i want it to look

Weld the particle to the torso, and use CFrame.Angles., Also use task.delay instead of task.spawn and task.wait().

uhh how exactly would i use cframe.angles if the position is… well… a vector? also i dont think welding it would help because it just makes it’s position relative to the torso’s, while i want it to be reflecting the move direction, but still thanks for the advice of task.delay, i completely forgot that exists

so you want the particle to be on the direction the player is going to and not the direction of where he’s looking at?

yeah exactly!!

awesomethirtycharacterslimit

hmm. currently im trying out (objecttoparticle.Position + objecttoparticle.Velocity) and it gives me good results so for now ill try using this and then maybe it will all work out

aand i got it to work!! all ive had to do was to add a little math.rad(90) to the x and z rotations on cframe.angles so now it looks like this
local cframe1 = CFrame.lookAt(objecttoparticle.Position, (objecttoparticle.Position + objecttoparticle.Velocity)) * CFrame.Angles(math.rad(90), math.rad(i * 36), math.rad(90)) * CFrame.new(0, 0, 5)
anyway sorry for posting i solved my own problem

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.