Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How Can I print, where an item is located in workspace?

Asked by
Borrahh 265 Moderation Voter
3 years ago
Edited 3 years ago

So basically, let's say when I hit a part, and its my right leg, is there a way i can make it print the location, eg:

OUTPUT: game.Players.PlayerName.Humanoid.RightLeg

0
You can try :GetFullName() zboi082007 270 — 3y

3 answers

Log in to vote
2
Answered by 3 years ago

supa dupa simple

script.Parent.Touched:Connect(function(hit)
    print(hit:GetFullName())
end)
0
Thanks, also thnx to others for trying to help, i accepted ur answer as you provided an example Borrahh 265 — 3y
Ad
Log in to vote
1
Answered by 3 years ago

Try this: Parent the script under the detection part

local detectPart = script.Parent

detectPart.Touched:Connect(function(part)
    if part then
        if part.Parent:FindFirstChild("Humanoid") or part.Parent.Parent:FindFirstChild("Humanoid") then

            print(part.Position)
        end
    end
end)
0
I don't understand how the part's parent's parent could be the player's character. Other than that, I agree with your answer. AntiWorldliness 868 — 3y
Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

Really easy to do! This script that I made down below checks if whatever touches the part is a humanoid (player) and prints what has touched the part.

script.Parent.Touched:Connect(function(hit)
        if hit.Parent:FindFirstChild("Humanoid") then
        print(hit.Name .." has touched the part") 
end)

Answer this question