Number 1. Sorry
- It says "Unable to cast to Array "
Number 1. Sorry
Yeah, sorry, never used this before. Let me research more on it.
well thats simple, its because the array isnt defined, so in XRay(script.Parent.PrimaryPart)
add another parameter which is an empty table: XRay(script.Parent.PrimaryPart, {})
and also the first parameter should be around an array, so it should look like this:
XRay({script.Parent.PrimaryPart}, {})
Yeah, as @mroaan said
local function XRay(castPoints, ignoreList)
ignoreList = ignoreList or {}
local parts = workspace.CurrentCamera:GetPartsObscuringTarget(castPoints, ignoreList)
for _, part in pairs(parts) do
part.LocalTransparencyModifier = 0.75
for _, child in pairs(part:GetChildren()) do
if child:IsA("Decal") or child:IsA("Texture") then
child.LocalTransparencyModifier = 0.75
end
end
end
end
while task.wait(0.3) do
XRay(script.Parent.PrimaryPart,{script.Parent})
end
Sorry lul
Also the previous script hid the player character too. Fixed that.
and the first parameter should be around an array.
Still says it cant cast a ray for some reason
the first parameter needs to be inside an array, just like in the documentation:
XRay({script.Parent.PrimaryPart})
edit: ignoring the playerâs character isnt really necessary since when you get in first person all your body parts disappears
Also put it in a loop so it always checks instead of once on startup.
Also by the edit, wdym, the game is a top-down view game-?
not necessarily when you get in first person, since its a top-down view game you pretty much dont need to ignore the playerâs character.
im not sure whats wrong in the videoâŚ
Sorry, itâs a file. I canât open it.
I have to head to bed But I will check for solutions after school
I have made a code:
I cast a ray from the humanoid root part to the camera part, If there is a roof the transparency is set to 0.8
local hrp = script.Parent.HumanoidRootPart
local cameraPart = Instance.new("Part")
cameraPart.Transparency = 1
cameraPart.CanCollide = false
cameraPart.Parent = workspace
cameraPart.Name = "cameraPart"
cameraPart.CFrame = CFrame.new(hrp.Position + Vector3.new(0, 40, 0), hrp.Position)
local bp = Instance.new("BodyPosition")
bp.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bp.Parent = cameraPart
wait(1)
while wait() do
local StartP = game.Workspace.cameraPart.Position
local EndP = script.Parent.HumanoidRootPart.Position + Vector3.new(0,3,0)
local result = workspace:Raycast(StartP, EndP - StartP)
if result then
if result.Instance.Name == "Roof" then
result.Instance.Transparency = 0.8
end
end
bp.Position = hrp.Position + Vector3.new(0, 50, 0)
end