Title YouTube Video Code:
script.Parent.Touched:connect(function(hit)
print(hit.Name)
if hit.Name=="SynthPlay" then
script.Parent.Sound:Play()
end
end)
Title YouTube Video Code:
script.Parent.Touched:connect(function(hit)
print(hit.Name)
if hit.Name=="SynthPlay" then
script.Parent.Sound:Play()
end
end)
I've seen the video. You've mispelled it.
You have the object in your workspace named "SnythPlay" instead of "SynthPlay". Be aware of spellings next time as it puts heavy problem/errors.
Try using this format from now on.
function onTouched(part)
if part.Parent ~= nil then
local h = part.Parent:findFirstChild(" Whatever object in workspace you want the script to detect on touch.")
if h~=nil then
--Do stuff
script.Parent.Touched:connect(onTouched)
Im trying to get whatever part it touches. This code is not a very good format.
Mine is more efficient
@Void_Frost How is your script deem more efficient if your script doesn't even work?
Joe, my script is easier, your script doesn't detect what is touched... only if it is touched.
@Void_Frost Then you have to mention that in your question. You expect the script to detect a part named "SynthPlay" to touch the object. That is what your script says.
No, i say whenever it is touched, IF it is SnythPlay, it will play a sound
JoeRaptor, at least include ends, man.
That depends on how many ends you would need. @PersonaCole
This should work for you:
script.Parent.Touched:Connect(function(hit)
print(hit)
if hit.Name == "d" then
print("It works!")
end
end)
This was tested. Please upvote and accept my answer if it helped!
Not Working
Is it in a server script.
Just updated my answer. Its working perfectly fine for me.
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
Are you trying to get the player who touched it?
No, trying to get a Collidable part that slides across