What I want to do is like a taser script, I’ve got the click event and stuff but I want a part to form from “FirePart” (defined as local fp) to the position of the mouse (defined as mousepos) which is a Vector3.
Example:
The mouse is aiming at this location so it has rotated and positioned itself to the location of the part
You will need to use Lerp for this, Lerp basically finds the point between 2 vector3s, Example Script, which forms a line from PointA to a Player.
local Part = Instance.new("Part")--Create Part
Part.Parent = workspace
Part.Anchored = true
Part.Size = Vector3.new(15,1,plrdistance)--Distance From Point A to B
Part.CanCollide = false
local BaseV3 = player.Character.HumanoidRootPart.Position
local Point2Position = Vector3.new()
Part.Position = Model.PrimaryPart.Position:Lerp(BaseV3, 0.5)--Moves the part exactly half way between Point A and B
Part.CFrame = CFrame.new(Part.Position,Point2Position)--Makes Part Look At Point
This isn’t exactly what you asked for but I hope it helps get you started,
local fp = --FirePart
local mousepos = --Position of mouse
local plrdistance = (fp.Position - mousepos).Magnitude
Pretty sure it’s this,
Here is how it would be with variables:
(this is @Wizard101fire90 's code, if it works mark their reply as the solution)
local fp = --FirePart
local mousepos = --Position of mouse
local plrdistance = (fp.Position - mousepos).Magnitude
local Part = Instance.new("Part")--Create Part
Part.Parent = workspace
Part.Anchored = true
Part.Size = Vector3.new(15,1,plrdistance)--Distance From Point A to B
Part.CanCollide = false
Part.Position = fp.Position:Lerp(mousepos, 0.5)--Moves the part exactly half way between Point A and B
Part.CFrame = CFrame.new(Part.Position,mousepos)--Makes Part Look At Point