Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make a part the size of a ray?

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)

1 answer

Instead of part.position do

Part.CFrame = CFrame.lookAt(origin, ray.Position)*CFrame.new(0, 0, -length/2)
end

This discussion is preserved as it was. New answers, comments, and votes are closed.