Is there a way to check if a player is touching a part?

I aleardy tried Touch and TouchEnded, btw it dosen’t work for me.
my current script:

while wait(.5) do
	local touching = game.Workspace:GetPartsInPart(game.Workspace.hitboxneprised)
	local playerInPart = false
	for i, v in pairs(touching) do
		if v.Parent:FindFirstChild("Humanoid") ~= nil then
			if v.Parent.Name ~= "dada" and v.Parent.Name ~= "Mother" then
				if v.Parent:FindFirstChild("Humanoid").WalkSpeed >= 10 then
					local msg = "Ни с места!"
					script.Parent.Head["271 _Ru_ _Mom_ _Chase_ Stop_"]:Play()
					game.ReplicatedStorage.TalkGui:FireAllClients(db,msg)
					script.Parent.Mom_PlayerAttack.Enabled = true
					wait(.3)
					game.Workspace.hitboxneprised.CanTouch = false
					game.SoundService["Chase-Main"]:Play()
					wait()
				end
			end
		end
	end
	print(playerInPart)
end

btw here why i need another way (very laggy sound and the attack script is not on):

It probably is detecting, you just forgot to set playerinpart to true once the player is detected. As for it being laggy, it’s because you are waiting a lot in the for loops

Playerinpart doesn’t mean anything, i just forgot to remove it. And about loops, if I make them longer, then the mother will not notice the player longer.

1 Like

nvm, I changed the script and now everything works great

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