Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why wont my script detect terrain in my game it only detects normal parts?

Asked by 3 years ago

So I am trying to making it when your camera is underwater it prints something but it doesn't work and it only works with parts and I want it to work with terrain.

Its on client and in starter character scripts Heres script:

while wait() do
    local rayorigin = game.Players.LocalPlayer.Character.HumanoidRootPart.Position
    local raydirec = game.Workspace.CurrentCamera.CFrame.Position

    local raypram = RaycastParams.new()
    raypram.FilterDescendantsInstances = {game.Workspace.Terrain}
    raypram.FilterType = Enum.RaycastFilterType.Whitelist

    local rayresult = workspace:Raycast(rayorigin, raydirec)

    local T = Instance.new("Part", workspace)
    local dis = (rayorigin - raydirec).Magnitude
    T.Anchored = true
    T.CFrame = CFrame.lookAt(raydirec, rayorigin)*CFrame.new(0, 0, -dis/2)
    T.Size = Vector3.new(.1,.1, dis)
    T.CanCollide = false
    T.Transparency = .7

    if rayresult then
        print(rayresult.Material)
    end
end

P.S. I tryed a normal script it still dont work

0
Going to check in like 10 - 15 mins so will be afk for a bit thanks to anyone thats helping! vortex767 20 — 3y

Answer this question