How: Simple script to see if a player is inside of a part or touching, part is collision off

Hi,

I have been searching around for the way of checking if a player is in a part or touching it, the part has collision off.

Example would be for PartA , run script , is the player in or touching PartA
I also looked at some resources like ZonePlus etc (which from what I see is a trigger event: enter exit, verses being able to query what zone / part a player is in currently.

And the player might be not moving inside of the part, ie kickn it, so an ENTERED trigger cannot be used because they might have entered it awhile ago…

I read a bit on this WorldRoot | Roblox Creator Documentation

and then maybe if the loop was checking for

if game.Players:getplayerfromcharacter(part.Parent)

Might work but have not found or figured out how to script it all together.

Thank you for any help!

local Part = "Your Part Here"


Part.Touched:Connect(function(hit) -- hit Variable to detect items

local Hum = hit.Parent:FindFirstChild("Humanoid") -- Finds Players Humanoid
if Hum then

print("Player Detected: ", tostring(hit.Parent.Name)) -- Converts Items Name to a String plus with another String
 end
end)

Should work without Part Collision.

Hi, Yes, thanks for the reply.

With your reply, it is still a triggered event, meaning when the part is touched it triggers. I am not looking for a triggered event.

What I am looking for is they are doing something else, lets say clicked on a prompt, then I want inside of the prompt code (the script code I am trying to figure out)

Is the current player inside of PartA?

( I probably should have added this for more clarity.)

Any other ideas you have are much appreciated.

Using Touched and TouchEnded to change a variable false or true then checking if the variable is true.

Yes, true, another thought I had, but I was looking for a real time check.

Also if you have a good number of parts that I am checking for at any given time ie prompt all over, they all would have to have a table for each player set up…

I think that if I I stored it in a each part (via a custom property in the part), it then becomes a server table of any player entering or exiting the part…

Perhaps their is an easier way of tracking it… I thought though reading about WorldRoot, it sound like it would work, it is just a matter of how do you loop through what it returns, and see if it is part of the players parts…

perhaps not the particular solution you are looking for as I don’t know the intricate functionalities of the module: ZonePlus functions can detect when a player enters a zone, touching? not sure.

edit: woops you already mention it

although don’t know why it wouldnt work for you?