How do I make a bullet go to raycasts end?

  1. Basically I want a bullet to travel to the raycasts end and after it’s done I want it to bounce off the part it hit.

  2. I don’t have no issues just wanna learn.

  3. this is my first time looking for a solution.

any help appreciated.

-- game.ReplicatedStorage.shot.OnServerEvent:Connect(function(player,pos)
	if canshoot == true then
		local ray = Ray.new(script.Parent.Cylinder13.Position, (pos - script.Parent.Cylinder13.Position).unit * 100)
		 local part, position = workspace:FindPartOnRay(ray, player.Character, false, true)
		local bullet = game.ReplicatedStorage.bullet:Clone()
		bullet.Parent = game.Workspace
		bullet.CFrame = CFrame.new(bullet.Position,pos)
		
	end
end)

I am not asking you to write the script for me and blindly copy paste it, just take me through the whole thing and we’ll see which one will be the solution for me.

Alright so first use TweenService or use RunService and move the bullet to the end. When it nears the end you want to basically make the part work like a mirror.

If I am not mistaken you get the Normal vector from the part, you can use this to get the mirrored direction you want.

Then you want to repeat the steps above until it mirrored enough times.

Use this tutorial for a more in-depth explaintion on how to mirror rays

See, when you use tweenservice you need to put in a time, for example we put 1 second, if the raycast is far it will go fast, if its close it’ll go slow so I don’t understand what to do there

I mean, sure you do need to put in the time, but instead you need to get the magnitude of the Vectors and put it as the time and then divide it so it’s faster. That’s how you can make it work.

Alright thanks bro complitelly missed the divide idea and the vector

1 Like

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