How to detect that the player is still touching the part?

I have a problem that is shown in the video

8 Likes

you can use region3, zoneplus or overlapparams to detect something in a zone/area

3 Likes

wat, im begginer in scripting soo i dont know what do u mean

3 Likes

just use a ray cast or a shape cast its really easy

1 Like

I need a part, not a raycast or a shapecast
and also for other users, too, it will be useful

then just use a hitbox module or what Moscow said

This is what I did for making a hiding spot where I needed to get when they are no longer touching it. (My game had bushes, and I needed to see if they were hiding, else, they would get caught by the monster)

local db = {}
local Part = nil --Change this to pathway of part.
Part.Touched:Connect(function(hit)
	if not table.find(db, hit.Parent.Name) and hit.Parent:FindFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(hit.Parent) then
		table.insert(db, hit.Parent.Name)
		local StillTouching = true
		print("Player Has started the touch event")
		repeat 
			local eachRound = false
			task.wait(0.1) 
			for i, v in Part:GetTouchingParts() do 
				if v.Parent == hit.Parent  and eachRound == false then
					StillTouching = true
					eachRound = true

				end
			end 

			if eachRound == false then
				StillTouching = false
			else
				print("Player is still touching this")
			end
		until StillTouching == false
		print("finished touching")
		table.remove(db, table.find(db, hit.Parent.Name))
	end

end)

Hope this helps and let me know if there is any errors~

1 Like

So what you want is for damage to be done while the player is touching the Part.
Use @OfficialPogCat’s script and where it says print("Player is still touching this") put a line that does a small damage to the player’s Health. This way each .1 seconds the script checks for the player touching the part, and if they are then it hurts them, but as soon as they leave it’ll stop.

what mean dp? you missed something and where table?

Ah sorry. It’s just an empty table. I have edited my post to add it in. (db is the debounce for this script to prevent the .Touched event from firing more then once per player)

2 Likes