How to see if a player is touching a part?

Hello, I have this .Touched event however exploiters are able to delete the object which rids the .touched event.

I’m trying to get an alternative to .touched

which takes into account the rotation of the part as well as the height and the radius. whenever a player collides with the part I want it to print hello

Here is the script I tried to make

local partsToPrintHello = {workspace.part1, workspace.part2}
local player = game.Players.KrimsonWoIf

for i,v in pairs(partsToPrintHello) do
 --  Start the alternative to .Touched()

local filterObjects = {}
local boxPosition = v:GetPivot()
local X,Y,Z = v.Size
local boxSize = Vector3.new(X+2,Y+2,Z+2)
local maxObjectsAllowed = 9999999
local params = OverlapParams.new(filterObjects,Enum.RaycastFilterType.Blacklist,maxObjectsAllowed,"Default")
local objectsInSpace = workspace:GetPartBoundsInBox(boxPosition,boxSize,params)

for i,v in pairs(objectsInSpace:GetChildren()) do
if v:IsDescendantOf(player.Character) then
print("Hello")
end
end
end
1 Like

Yes, I did since you used a lot of variables that I don’t really want to read through. Now, why do you need an alternative to .Touched?

you answered your own question.

It’s fairly simple, use a Signal class to wrap and secure the events. Also remember to disconnect your events!

How are exploiters deleting parts on the server side?
I ask this because I’m trying to understand the full situation. And I don’t know a lot about what is possible for exploiters to do.

So I assume that because of “filtering enabled”, an exploiter can delete a part on their client-side, but unless there is a remote function/event that allows them to delete a part, there isn’t much they can do to destroy this part. Like if they delete it on their client, the server one will still be there. And I assume they would still be influented by the touch event. But the client would become out-of-sync.


With that being said, your code is going on the right track of a alternative “touch detection”. But I don’t know if there is a specific issue the current code you’ve shown is having, and that’s why your asking.

Also, even with this code, if the exploiter still manages to destroy a part, would this code continue to work? Like, this code uses a list of parts, but if one is deleted, then the list would still have a reference to it. Which could have unexpected results.

I believe if the player locally never touches the part it won’t recognize it on the server even if you’re using the server to manage the .touched event

1 Like

yes this is the reason why. Its most likely this way because of resource intensivness. However these .touched events larger dictate how my game works and I am not a fan of exploiters.

That is good to know.


With that being said. I do know there also is a few other special functions for getting “interaction info” reguarding parts.

From KrimsonsWolf’s code, there is “GetPartBoundsInBox”

But from a quick search, there is also “GetPartsInPart” which is more flexible and might simplify your code a bit.

But like I said, your code looks like it’s generally doing what you’d want to do, check and see what parts are overlapping these “special parts”, and doing somthing if it’s a part of a player.

1 Like

If you can go into more detail about what the game is about I can help come up with some ways to design it in ways that are difficult to exploit.

1 Like

Interaction info wouldn’t be relevant if the part isn’t being touched, and that’s why I think he needs to go about it a different way

hello I am not looking for ways that

but rather impossible to exploit. the same way that its impossible for a exploit to delete a script in serverscriptservice.

If your game is just about interactions with parts you’re out of luck in making it impossible. There’s only so much you can do in this situation

1 Like

I believe you must be new to roblox scripting and dont fully understand client vs server interactions. are you saying that exploits are able to access the serverscriptservice?

Just image the message you sent but instead of that put into something more understandable:

you bassically just said

I’m quite experienced, I was simply asking for more specifics on the gameplay so I can think of other ways to go about it. Also that is not at all what I said, it is impossible for people to access scripts in serverscriptservice. I’d like to mention you made the edit “the same way that its impossible for a exploit to delete a script in serverscriptservice.” after I had already replied

1 Like

I told you everything you need to know. I simplified my issue so you could provide me a solution without having to take my actual problem head on. I bassically sugar coated it to make it easier.

Please solve the sugar coated issue I told you in my post and I will use that solution to fix my games issue,

(The code which I provided is impossible to exploit however it doesnt take into account rotation even if an exploiter deletes the part, it will still detect hits)

just do this on the server or set the network owner to server.