:GetTouchingParts() not working

I have never experienced this before, but for some reason, :GetTouchingParts() only works sometimes. This should not be an issue, but it is called on the client.

Is this an engine bug or something?

Could you provide the script? Maybe the issue is in there

1 Like

thats the full section of code:

TweenService:Create(Part, TweenInfo.new(Time, Enum.EasingStyle.Quad), Property):Play()
		
local TouchedConnection = Part.Touched:Connect(function()end)
local Connection
local OldPos = Part.Position
	
Connection = RunService.RenderStepped:Connect(function(DeltaTime)
	if OldPos == Part.Position then
		TouchedConnection:Disconnect()
		Connection:Disconnect()
	end
	
	local TouchingParts = Part:GetTouchingParts()
	print(Part:GetTouchingParts())
	if #TouchingParts <= 0 then
		OldPos = Part.Position
		return
	end
	for PartCount, PartTouch in pairs(TouchingParts) do
		local Player = PlayerName(PartTouch:FindFirstAncestorWhichIsA("Model"))
		if not Player then
			OldPos = Part.Position
			return
		end
	end
	local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
	local CharacterRootPart = Character.PrimaryPart
	
	CharacterRootPart.CFrame = CFrame.new(CharacterRootPart.Position + ((Part.Position - OldPos) * Part.Slippery.Value)) * CFrame.Angles(math.rad(CharacterRootPart.Orientation.X), math.rad(CharacterRootPart.Orientation.Y), math.rad(CharacterRootPart.Orientation.Z))
	
	OldPos = Part.Position
end)

Hello, I believe I’ve had this same issue in the past and came across a weird fix on the forums. Apparently, GetTouchingParts only work if there is a touched connection active on the part. I see you already have one in the script, and could just move the disconnect part down, or you could do this:

local connection = Part.Touched:Connect(function() end)
local TouchingParts = Part:GetTouchingParts()
connection:Disconnect()

Hope this helps!

3 Likes

still does not work even after that.

Your instance must include TouchTransmister, You could add him just buy using:

local = obj = my.path :: part
obj.Touched:Connect(function() end)

There is a touch transmitter though, I add it here and remove it when the part is done moving (it does get readded when it starts moving again though).

1 Like

just go to your part and insert a script:

script.Parent.Touched:Connect(function() end)

should work. But I dare you not to use this function, cuz better Idea is to use ZonePlus module.

You could use :GetPartsInPart(), a method of workspace/WorldRoot

It says “This method can be used in place of BasePart:GetTouchingParts() and is generally a better choice.”

You could try that to see if it fixes anything

still results in the same issue, do you think its due to it being handled on the client?

1 Like

Yea I’ve tried to use Touched, GetTouchingParts etc on the client and they don’t seem to work well. Switching to the server has always fixed it for me.

Using GetPartsInPart() will work like @Noobyoply said, just make sure the OverlapParams are set correctly and your parts are not in another collision group, and if so, make sure the collision group is set to one that collides with that collision group.

It looks like that this is caused by desync between the movement from the tweening and the character’s position being updated in response, causing a brief period where the tweened part is effectively inside of the character and that would be why it thinks it is touching the legs as well as the feet. I assume you are trying to make a slippery part that moves? I would suggest trying to mess around with the part’s physical properties rather than making it through scripting, as it now gives the problem to the game engine itself (the physics portion of it) to solve rather than multiple desyncing scripts. This might help you figure out how to do it

If the physical properties doesn’t work out, you should be able to still accomplish it with scripts. Just keep in mind that this is expected behaviour from the function and what it normally does

it has been solved by calculating the position of the player, and basing that off of the position of the part. It works and isnt that laggy. Thank you all for your help though.

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