Im trying to create a Raycast that only you can see with a keybind that connects from your HumanoidRootPart to anyone elses HumanoidRootPart, and im wondering how would I do so?
Example
Basic Visualized Raycast Script
local function VisibleRay(ray)
local MidPoint = ray.Origin + ray.Direction / 2
local Part = Instance.new("Part", workspace)
Part.Anchored = true
Part.CanCollide = false
Part.CFrame = CFrame.lookAt(MidPoint, ray.Origin)
Part.Size = Vector3.new(Size, Size, ray.Direction.magnitude)
return Part
end
local StartCFrame = game.Workspace.Start.CFrame -- the block that sends the raycast
local TargetCFrame = game.Workspace.Target.CFrame -- block that receives the raycast
local StartPosition = StartCFrame.Position --position you want the ray to start at
local Distance = (StartPosition - TargetCFrame.Position).magnitude --how far you want the ray to go (the distance between the two parts)
local ray = Ray.new(StartPosition, (TargetCFrame.Position - StartPosition).Unit * Distance) --creating the ray
VisibleRay(ray)