This is what I currently have
part.CanCollide = false part.Name = "Ray" part.Anchored = true part.BrickColor = BrickColor.new("Crimson") part.Transparency = .4 part.Size = Vector3.new((mob.Head.Position - centerOfTheMap.Position).magnitude,.2,.2) part.Position = ((mob.Head.Position+centerOfTheMap.Position)/2) part.Parent = workspace
But I don't quite grasp how CFrame works and I can't seem able to make the part go through two point's in space.
Working with CFrame
is a lot like working with Part.Position
, though there is a difference. Whenever you change a Part
's position or rotation in space, you should use CFrame, not Part.Position
. Using Part.Position
can create unwanted and unexpected effects. It is quite simple, actually:
part.CanCollide = false part.Name = "Ray" --Note, of course, that you don't have to indent part.Anchored = true part.BrickColor = BrickColor.new("Crimson") part.Transparency = .4 part.Size = Vector3.new((mob.Head.Position - centerOfTheMap.Position).magnitude,.2,.2) part.CFrame = CFrame.new((mob.Head.Position+centerOfTheMap.Position)/2) --Instead of position, with Vector3.new, use CFrame, with CFrame.new part.Parent = workspace
This is the Wiki page for CFrames, since there is lots more that you can do with it: http://wiki.roblox.com/index.php?title=CFrame
To create a part between two points:
--create the points local pos1 = Vector3.new() local pos2 = Vector3.new(10,10,10) --get information local diff = pos2-pos1 local dist = diff.magnitude local center = pos2 - (diff/2) --create the part local part = Instance.new('Part',workspace) part.Anchored=true --simple part.Size = Vector3.new(1,1,dist) --first argument is position, second argument is what to look at... part.CFrame = CFrame.new(center,pos2)