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

Script.Parent.Touched:Connect() not seeming to function properly?

Asked by 4 years ago

My script that I wrote that shows no sign of error is not working. Could anyone explain to me why this is? Any help would be appreciated!

function OnTouch(hit)
    print(hit.Name.."hit me!")
    if hit:IsA("MeshPart") then
       print(hit.Name.."hit me!")
       game.ReplicatedStorage:WaitForChild("vals"):WaitForChild("Winner").Value = hit.Name
       script.Parent:Destroy()
    end
end

script.Parent.Touched:Connect(OnTouch)

1 answer

Log in to vote
0
Answered by
Lucke0051 165
4 years ago
Edited 4 years ago

I assume you are trying to get the character that hit the part, if so you should check all parts that hit it if their parent is a players character. If you could explain your problem further it would be helpful, is it printing?

print(hit.Name.."hit me!")

Ad

Answer this question