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

Function (hit) does not always register?

Asked by 5 years ago

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?

0
I don't think this is the problem, but use uppercase ``:Connect()`` instead of lowercase ``:connect()`` IceAndNull 142 — 5y
0
Maybe because you aren't destroying the part that is touched and the new part is touching the invisible part. DevOfLua 13 — 5y
0
:connect is depricated, instead use :Connect Gameplayer365247v2 1055 — 5y
0
omg you people stop giving stupid answers DeceptiveCaster 3761 — 5y
View all comments (2 more)
0
Anyway, you're saying that you're changing the property in-game and it isn't working? DeceptiveCaster 3761 — 5y
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. DevOfLua 13 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago
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

0
and that is because hit is the scripts parent Gameplayer365247v2 1055 — 5y
0
Nope. The scripts are fine. It's just roblox who doesn't trigger the script if it's cloned from Lighting to workspace. HeadlessDeathSpeaker 9 — 5y
0
why do u keep a part in lighting Gameplayer365247v2 1055 — 5y
Ad

Answer this question