I can't seem to find a way to detect R6 bodyparts. Help?
ToolDetector.Touched:Connect(function(hit)
if hit.Parent.Name == "Left Leg" or "Right Leg" or "Torso" or "Right Arm" or "Left Arm" or "Head" then
print(hit.Parent.Name.. " has touched the metal detector.")
playerCharacter = hit.Parent
hitPlayer = game.Players:FindFirstChild(hit.Parent.Name)
loggedPlayer = game.Players:FindFirstChild(LoggedUser.Value)
loggedGui = loggedPlayer.PlayerGui:FindFirstChild("MetalDetectorGui")
playerBackpack = game.Players:FindFirstChild(hit.Parent.Name).Backpack
loggedGui.username.Text = playerCharacter.Name
for i, v in pairs(playerBackpack:GetChildren()) do
print(v)
loggedGui.items.Text = "backpack: "..v..""
end
else
end
end)
The Whole Script:
--Settings
GroupID = 4994106
minimunRank = 0 -- Get the number of your role and subtract it by one.
-- ** Do not edit anything else further on. **
Body = {"Left Leg", "Right Leg", "Torso", "Right Arm", "Left Arm", "Head"}
Screen = script.Parent.Parent.Screen
ScreenClickDetector = Screen.ClickDetector
LoggedUser = script.Parent.LoggedUser
groupRank = ""
ScreenGui = script.Parent.MetalDetectorGui
ToolDetector = script.Parent.Parent.ToolDetector
ScreenClickDetector.MouseClick:Connect(function(player)
groupRank = player:GetRankInGroup(GroupID)
if groupRank <= minimunRank then
print("'"..player.Name.."' has Attempted to log into a metal detector.")
else
local ScreenClone = ScreenGui:Clone()
ScreenClone.Parent = player.PlayerGui
LoggedUser.Value = player.Name
end
end)
ToolDetector.Touched:Connect(function(hit)
if hit.Parent.Name == "Left Leg" or "Right Leg" or "Torso" or "Right Arm" or "Left Arm" or "Head" then
print(hit.Parent.Name.. " has touched the metal detector.")
playerCharacter = hit.Parent
hitPlayer = game.Players:FindFirstChild(hit.Parent.Name)
loggedPlayer = game.Players:FindFirstChild(LoggedUser.Value)
loggedGui = loggedPlayer.PlayerGui:FindFirstChild("MetalDetectorGui")
playerBackpack = game.Players:FindFirstChild(hit.Parent.Name).Backpack
loggedGui.username.Text = playerCharacter.Name
for i, v in pairs(playerBackpack:GetChildren()) do
print(v)
loggedGui.items.Text = "backpack: "..v..""
end
else
end
end)

2 comments
You're checking the hit.Parents name, that would be the character. You have to check the hit's Name. hit.Name == "Left Leg", you could also use if hit:IsA("Part") then etc. That will check if hit is a part, not an accessory.
Thanks very much!