Why Cannot use "IsTouching" On RootPart

Hello, I am trying to make drowning system and here is some problem

IsTouching is not a valid member of Part “Workspace.MoonScro.HumanoidRootPart”

Can I have any solution?


local function TouchingWater()
	local player = game.Players.LocalPlayer
	local character = player.Character
	if character then
		local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
		if humanoidRootPart then
			local waterPart = game.Workspace:FindFirstChild("Water")
			if waterPart then
				if humanoidRootPart:IsTouching(waterPart) then
					print(player.Name .. " is touching water!")
				end
			end
		end
	end
end

while true do
	wait(0.1) 
	TouchingWater()
end

2 Likes

The error is self-explanatory; IsTouching doesn’t exist in the roblox api. The closest thing to this is WorldRoot.GetPartsInPart.

if table.find(workspace:GetPartsInPart(humanoidRootPart), waterPart) then
	print(player.Name .. " is touching water!")
end
3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.