Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why Doesn't The Script Print Detected When Part Is Hit?

The Purpose Of This Script is to detect if a part (The Part Is The Parent Of The Script) touches another part named "SauceDetector". The Part "SauceDetector" is an unanchored, can collide off part the falls from right above the Part and touches the part. For some reason the Print("SauceDetected") Doesn't Print.

function onTouched(hit)
if hit.Parent.Name == "SauceDetector" then
	print("SauceDetected")
script.Parent.Sauce.Value = true
end
if hit.Parent.Name == "CheeseDetector" then
script.Parent.Cheese.Value = true
end
if hit.Parent.Name == "PepperoniDetector" then
script.Parent.Pepperoni.Value = true
end
if hit.Parent.Name == "MushroomDetector" then
script.Parent.Mushroom.Value = true
end
end
script.Parent.Touched:connect(onTouched)

If You Know Why Its Not Detecting Please Let Me Know!

1 answer

I think it's not printing as you say "hit.Parent.Name" which I think is the workspace.

To fix this, instead of putting hit.Parent.Name, say hit.Name in each of them.

6 comments

1

Hit.Parent.Name should return the Handle of your Character; username

1

So you're correct, he's asking if the Username is equal to "SauceDetector", which will never be true, unless someone is that random

0

@Ihatecars100, I tried changing hit.Parent.Name to hit.Name and it didn't work :/ Also @simplealgorithm, I'm trying to Print("SauceDetector") if the Part touches a Part Named SauceDetector, Not A Player.

0

@kizi3000 maybe try changing :connect() to :Connect()?

0

still doesn't work :/

0

are you definitely sure the part that's hitting is called "SauceDetector?"

This discussion is preserved as it was. New answers, comments, and votes are closed.