i have been trying to make my part the size of the ray but i do not know what to put. I would appreciate if someone would help me out.
Here is my code
local RemoteEvent = game.ReplicatedStorage.RemoteEvent RemoteEvent.OnServerEvent:Connect(function(Player,mouseCframe) local Mouse = Player:GetMouse() local Origin = script.Parent.Position local Direction = (mouseCframe - Origin).Unit Direction = Direction * 100 local ray = Ray.new(Origin,Direction) local Parts = workspace:FindPartOnRay(ray,nil) print(Parts) local Part = Instance.new("Part",game.Workspace) Part.Anchored = true local length = (Direction - Origin).Magnitude Part.Size = Vector3.new(0.5,0.5,length) Part.Position = ??? end)
Instead of part.position do
Part.CFrame = CFrame.lookAt(origin, ray.Position)*CFrame.new(0, 0, -length/2) end