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
script.Parent.Fire.OnServerEvent:Connect(function(player,mousePos)
FireAudio:Play()
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
end
end)
Feel free to let me know if you need more information!