Issue with touched and touch ended

No it wouldnt work. It will cause errors and coroutine is improperly used. I know it can cause performance issues, but youre just gonna have to use a tick function with GetPartsInPart.

here. this only changes values when it detects a change or a missing player.

local AllPlayersInside = {}
function RecurssiveParent(Obj)
	local player =game.Players:GetPlayerFromCharacter(Obj)
	if player then
		return Obj
	elseif Obj.Parent ==workspace then
		return false
	else 
		return RecurssiveParent(Obj.Parent)
	end
end
while true do
	wait(.1)
	local AllTouchingParts = workspace:GetPartsInPart(script.Parent)
	local Flag=false
	for __,element in pairs(AllPlayersInside)do
		element.Value=false
	end
	for __,element in pairs(AllTouchingParts) do
		local PlayerObj=RecurssiveParent(element)
		if PlayerObj then
			if AllPlayersInside[PlayerObj.Name]==nil then
				local Player = game:GetService("Players"):GetPlayerFromCharacter(PlayerObj)
				Player:WaitForChild("Indoor").Value=true
				AllPlayersInside[PlayerObj.Name] = {Player=Player,Value=true}
			else
				AllPlayersInside[PlayerObj.Name].Value=true
			end
		end
	end
	for index,element in pairs(AllPlayersInside) do
		if not element.Value then
			element.Player:WaitForChild("Indoor").Value=false
			AllPlayersInside[index]=nil
		end
	end
end
1 Like

Everything is working right, thank you for your help!

1 Like

Of course i don’t close this post, anyone can write here if someone has better ideas.

I hope that will also help other people who don’t have access to developer forum.

A check every half second can do.

Doing a bigger number will ease up on lag, but allow players to have even bigger iframes

This is true, but I think this is better than having a laggy game. To reduce lag, you can add some overlap params so it doesn’t query what it shouldn’t have to.

Could you guys help me with another topic please?

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