[ SOLVED ] Ray does not detect parts

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    When a part is in front of the player, it’s transparency becomes 0.75
  2. What is the issue?
    Ray does not detect part

here is the code:

wait(1)

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
--local castPoints = workspace:WaitForChild("CastPoints"):WaitForChild("Part").CFrame.p
--local ignorelist = {}

local RunService = game:GetService("RunService")
RunService.RenderStepped:Connect(function()
local function ArealTransparency(p0, p1)
		local d = p1 - p0
		local ray = Ray.new(p0, d)
		local PartsObscuring = {}
		repeat
			local p = workspace:FindPartOnRayWithIgnoreList(ray, PartsObscuring)
			table.insert(PartsObscuring, p)
		until not p
		return PartsObscuring
	end

	local Obscuring = ArealTransparency(workspace.Camera.CFrame.p, char.Head.Position)
		print(Obscuring.Name)
		Obscuring.Transparency = .75
end)

I think there might be a problem with the “repeat until” part of the code, but I really don’t know how to fix this.

1 Like

Don’t use FindPartOnRay, its deprecated and old

And that code is extremly messy and hard to understand, why are you repeating?

Run a heartbeat loop; raycast every frame step; if you detect a part that you want transparent, make it transparent?

Don’t use repeat until, use a loop

1 Like

I fixed the problem already, but did not close the post, sorry for taking your time.
I was just too focused on the “FindPartOnRay” thing, that’s why I did very weird and messy, for something wich isn’t that hard.
Thank you for you help tho!

1 Like

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