You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I am attempting to make a raycast gun that creates a part at a raycast intersection. I can use the old method of Ray.new
but since the tutorial page for it is gone I assume it is going to be deprecated in favor of workspace:Raycast()
. I am attempting to make the gun register a hit.
- What is the issue? Include screenshots / videos if possible!
The main issue is the error i get saying the result is nil. I know what that means but I am clearly pointing the gun at the ground with the exitCFrame is looking out the guns barrel but it still is not registering a hit.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried began by looking at the documentation for workspace:Raycast()
but it looks all good to me. I then went to different dev discords but since this method is new I cant find any answers.
Here is my current code I have in my module.
function RayService:CreateRay(origin, endPos, playerName)
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {workspace.Baseplate}
raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
local result = workspace:Raycast(origin, endPos, raycastParams)
local part = Instance.new("Part")
part.Parent = workspace
part.Anchored = true
part.Position = result.Position
end
return RayService