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

1 comment
Going to check in like 10 - 15 mins so will be afk for a bit thanks to anyone thats helping!