local undebounce = true function onTouched(hit) -- Gets hit if undebounce then undebounce = false if hit.Parent.Name:lower() == "Baseball" then -- This is a tool but I tried putting handle as well still not working... script.Parent.Text = "Foul!" -- This is in a message... end end- Ends wait(2) -- Remove this if you only want the script to work once undebounce = true -- Remove this if you only want the script to work once end - Ends script.Parent.Touched:connect(onTouched) -- Connects to the function
Well, I've updated your code with a debounce, and I think the problem is the part where it says NameOfPart
, I think you have to change it to a different name.
local undebounce = true -- debounce function onTouched(hit) -- the function's Name if undebounce then undebounce = false if hit.Parent.Name:lower() == "NameOfPart" then -- I'm not sure if you forgot to change this part right here 'NameOfPart' to a different name script.Parent.Text = "Text" -- Do you mean the Name of a Brick, Text of a Message, or the Text of a GUI? end end -- Ends wait(2) --Remove this if you only want script to work only once undebounce = true --Remove this if you only want script to work only once end -- End script.Parent.Touched:connect(onTouched) -- connects the function