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

Should I put it "hit.Name" or "hit.Parent.Name"?

Asked by 5 years ago
Edited 5 years ago

So... I have this script that has to run when a specific part touches the brick it's in. But I'm unsure if I have to put "hit.Name" or "hit.Parent.Name" in line 3.

Can someone help me out with this?

function onTouched(hit)
    game.Workspace.Coll2.CanCollide = true
    if hit.Parent.Name == "DoNotTouch" then
    workspace.Ring.BodyAngularVelocity.AngularVelocity = Vector3.new(0,0,0)
    workspace.DoorsMain2Open.Script.Disabled = false
    workspace.BarsOpen.Script.Disabled = false
    workspace.ClickMAIN.ClickDetector.MaxActivationDistance = 32]]
    script.Disabled = true
    end
end

script.Parent.Touched:connect(onTouched)

2 answers

Log in to vote
1
Answered by
Webm07 43
5 years ago
Edited 5 years ago

It depends on what is touching it. If its part of a player, OR part of a bigger model, you would use hit.Parent.Name

Otherwise, you would just use hit.Name

Hope this helps!

Ad
Log in to vote
0
Answered by
Nogalo 148
5 years ago

It would be best and easiest to use

if hit.Parent:FindFirstChild("DoNotTouch") then

Answer this question