'position' is not a valid member of RaycastResult

I’m trying to make it so the gun creates a part where the ray hits a part, but it says ‘position’ is not a valid member of RaycastResult, which is a very weird error since even the official developer hub says it is.
I have tried several other things, none of them seem to work.

local FireAudio = script.Parent.Handle.Fire

	local raycastParams = RaycastParams.new()
	raycastParams.FilterDescendantsInstances = {player.Character}
	raycastParams.FilterType = Enum.RaycastFilterType.Blacklist

	local rayResult = workspace:Raycast(script.Parent.Handle.Position,(mousePos - script.Parent.Handle.Position)*50,,raycastParams)

	if rayResult then
		local hitPart = rayResult.Instance
		local laser = Instance.new("Part")
		laser.Anchored = true
		laser.CanCollide = true
		laser.BrickColor = BrickColor.new("Lapis")
		laser.Size = Vector3.new(.05,.05,.05)
		laser.Name = ("BlueLaser")
		laser.Position = Vector3.new(rayResult.position)
		laser.Parent = game.Workspace

Feel free to let me know if you need more information!

1 Like

Lua(u) is case-sensitive, the property name is Position, not position.

- laser.Position = Vector3.new(rayResult.position)
+ laser.Position = rayResult.Position

By the way the parentheses here are unnecessary.