Hey, everyone!
Quick question. What would be the most efficient way to detect if a player’s character is touching any other object in the workspace?
Thanks in advance.
Hey, everyone!
Quick question. What would be the most efficient way to detect if a player’s character is touching any other object in the workspace?
Thanks in advance.
How would I use this for determining if a part is touching the whole character model?
Why do you need the whole character model?
You can take into mind that any character is made up of a Humanoid
You can make an event on the Torso or HumanoidRootPart I prefer to use root part.
This event can be a .Touched event which fires when the player touches the Torso/RootPart and you can check for :GetTouchingParts() for all of the character’s parts such as Right Arm, Left Arm, Head and etc.
You can then compare if the instance which the Torso has touched is the same as the other body parts when you call :GetTouchingParts().
Notes:
If you want to do vice versa then you can do this
Part1.Touched:Connect(function(part2)
local Player = Players:GetPlayerFromCharacter(part2.Parent) -- Checks and returns if the part associates to a player
if Player then
for i,TouchingParts in pairs (Part2:GetTouchingParts())do
-- Check if all body parts of the player is touching
end
end
end)
Didn’t put everything there because its something you may know or learn
I need the whole model because I’m making a skydiving script, and I need to know when the player lands so that I can return the character movement back to normal. It’s similar to a battle royale game. When the player touches the ground or a house, I want to then return movement to normal.
After I made this post, I used Humanoid.Touched, and it wasn’t very reliable. Would the method you describe in your post be a better solution?
Try purely using TouchInterest and :GetTouchingParts()
:)Thanks from Future Person
Thank You!
I will finally be able to make hitboxes.