You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve?
When part is in front of a player, its transparency is .75, and when its not in front of the player anymore, its transparency goes back to 0. + I need to make the raycast detecting multiple parts. -
What is the issue?
Raycast not working at all. No result and no errors in output.
here is the code:
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local function raycast(p0, p1, ignoreParts)
local ignoreTable = ignoreParts
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Exclude
params.IgnoreWater = true
params.FilterDescendantsInstances = {ignoreTable}
local hitItems = {}
local finished = false
repeat
params.FilterType = Enum.RaycastFilterType.Exclude
params.IgnoreWater = true
params.FilterDescendantsInstances = {ignoreTable}
local result = workspace:Raycast(p0, p1 - p0, params)
if result then
if result.Instance then
table.insert(hitItems, result.Instance)
table.insert(ignoreTable, result.Instance)
print("Instance Found!")
else
print("No more instance")
finished = true
end
task.wait()
end
task.wait()
until finished == true
return hitItems
end
local p0 = workspace.CurrentCamera.CFrame.p
local p1 = player.Character:FindFirstChild("HumanoidRootPart").Position
local ignore = {char:GetDescendants()}
while true do
task.wait()
local items = raycast(p0, p1, ignore)
end
I really dont know what to do