Im new to raycasting, and i viewed a few dev forums and they didnt seem to work for me.
local From = workspace:WaitForChild("From")
local To = workspace:WaitForChild("To")
local Direction = From.Position - To.Position
local Params = RaycastParams.new()
local Result = workspace:Raycast(From.Position, Direction)
if Result and Result.Instance then
Result.Instance.Color =Color3.new(1,0,0)
end
local From = workspace:WaitForChild("From")
local To = workspace:WaitForChild("To")
local Direction = From.Position - To.Position
local Params = RaycastParams.new()
local Result = workspace:Raycast(From.Position, Direction)
if Result then
Result.Instance.Color = Color3.FromRGB(1,0,0)
else
warn("No raycast result!")
end
local RaycastParameters = RaycastParams.new()
RaycastParameters.IgnoreWater = true
RaycastParameters.RespectCanCollide = false
RaycastParameters.FilterType = Enum.RaycastFilterType.Exclude
local Raycast = workspace:Raycast(game.Workspace.Start.Position, game.Workspace.Start.CFrame.LookVector * 300, RaycastParameters)
if Raycast and Raycast.Instance then
Raycast.Instance.Color = Color3.new(0,1,0)
end
i think the the direction should be To.Position - From.Position because the difference of two points has the target or going to position as the minuend while the starting or coming from position is the subtrahend
local From = workspace:WaitForChild("From")
local To = workspace:WaitForChild("To")
local Direction = To.Position - From.Position
local Params = RaycastParams.new()
local Result = workspace:Raycast(From.Position, Direction)
if Result and Result.Instance then
Result.Instance.Color = Color3.new(1,0,0)
end