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

Function (hit) does not always register?

Howdy.

I'm just using this little script:

wait()
script.Parent.Touched:connect(function(hit) --Activates when hit
  if hit.Name == "Objection" then --detects the name and runs the code
 script.Parent.Transparency = 1
 end
end)

And. When i'm going to run my game. The brick doesn't always turn Trans 1 when touched by the object.

And sometimes it works...

Example: When i go in play mode (studio) and un-anchored my brick that should touch it, it won't register it. But, when it's already unanchored and then go play, it's being registered?

6 comments

0

I don't think this is the problem, but use uppercase :Connect() instead of lowercase :connect()

0

Maybe because you aren't destroying the part that is touched and the new part is touching the invisible part.

0

:connect is depricated, instead use :Connect

0

omg you people stop giving stupid answers

0

Anyway, you're saying that you're changing the property in-game and it isn't working?

0

https://imgur.com/a/cE0AO4u

Explain me this how is part 1 going to register part2's touch when part3 is in between them.

1 answer

wait()
script.Parent.Touched:connect(function(hit) --Activates when hit
  if hit.Name == "Objection" then --detects the name and runs the code
 script.Parent.Transparency = 1
 end
end)

in this script you are saying when someone tough the part then if the parts name is objection then it will make the part invisible, i think you need to do this instead

wait()
script.Parent.Touched:Connect(function(hit) --Activates when hit
  if hit.Parent.Name == "Objection" then --detects the name and runs the code
 script.Parent.Transparency = 1
 end
end)

this will check if the part that touched the scripts parent got the name objection and if it does chane the transparency of the scripts parent

3 comments

0

and that is because hit is the scripts parent

0

Nope. The scripts are fine. It's just roblox who doesn't trigger the script if it's cloned from Lighting to workspace.

0

why do u keep a part in lighting

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