Position is not a valid member of RaycastResult

  1. What do I want to achieve?
    A working script.

  2. What is the issue?
    I get this error no matter what i do.
    image

This is the script snippet:

local raycastParams = RaycastParams.new()
		raycastParams.FilterType = Enum.RaycastFilterType.Exclude
		raycastParams.FilterDescendantsInstances = {Character, game.Workspace:WaitForChild("EnvironmentTriggers"), game.Workspace:WaitForChild("TerrainTriggers"), game.Workspace:WaitForChild("SoundRegions"), game.Workspace:WaitForChild("BuoyGivers")}
		
		local lastCFrame = clone.CFrame
		local raycastResults = game.Workspace:Raycast(Character:WaitForChild("Head").Position, mouse.UnitRay.Position * 1000, raycastParams)
		
		local hitPosition = raycastResults.Position

		local part = Instance.new("Part")
		part.Position = hitPosition
		part.Size = Vector3.new(0.125,0.125,0.125)
		part.Anchored = true
		part.CanCollide = false
		part.CanQuery = false
		part.Material = Enum.Material.Neon
		part.Parent = game.Workspace
  1. What solutions have I tried so far?
  • Looking on the developer hub

This is a part of a script that is situated inside a Runservice.RenderStepped function

local hitPosition = raycastResults.Instance.Position

UnitRay is a Ray, not a BasePart; it only has three properties: Unit, Origin, and Direction (all Vector3s)

You’d likely want to use Direction here

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.