I have a script I’m using to fill a bucket. When you click it, it will print the result, and if eventually it will do something if it’s water. My only issue right now is that it only works on “sloped” terrain water, and not on flat terrain water or underwater. How can I fix this so that it works on sloped and flat water?
script.Parent.Activated:Connect(function()
local RunService = game:GetService("RunService")
local character = script.Parent.Parent
local humanoid = character:WaitForChild("Humanoid") :: Humanoid
local rootPart = humanoid.RootPart :: BasePart
if not rootPart then
humanoid:GetPropertyChangedSignal("RootPart"):Wait()
rootPart = humanoid.RootPart :: BasePart
end
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.FilterDescendantsInstances = {character}
local raycastResult = workspace:Blockcast(rootPart.CFrame, rootPart.Size, rootPart.CFrame.LookVector, raycastParams)
if raycastResult then
print(raycastResult.Material)
end
end)