How can i create a part that grows in the direction of where your mouse aim ?
There is a script that create a beam in front of you when you click with the mouse. Normally, the beam is supposed to grows to where you clicked with the mouse until a certain size (It does not grows over a certains size, for example : 75). Also, only the front part must grows.
When you click, the part appears a grows.... from both side (Front and Back) and i dont know how to change the position to make the begining of the beam always starts in front of you and the end finishes to where you click.
I've used Ray and CFrame to define the first position (when you just clicked) but not the position for when it's growing.
I mean :
01 | local tool = script.Parent |
02 | local ray = Ray.new(tool.Emitter.CFrame.p, (player:GetMouse().Hit.p - tool.Emitter.CFrame.p).unit * 75 ) |
03 | local part,position = game.Workspace:FindPartOnRay(ray, player.Character, false , false ) |
05 | game.ReplicatedStorage.Beam:FireServer(tool, position) |
11 | game.ReplicatedStorage.Beam.OnServerEvent:connect( function (player, tool, position) |
12 | local distance = (tool.Emitter.CFrame.p - position).magnitude |
14 | for i = 0 ,distance, 6 do |
15 | beam.CFrame = CFrame.new(tool.Emitter.CFrame.p, position) |
20 | beam.Size = beam.Size + Vector 3. new( 0 , 0 , 2.96 ) |
Now , all i need is to define the position each time the part grows, but i dont know how to do this. Could someone help me ?