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

My Touched function won't work, why?

Asked by 9 years ago
script.Parent.Touched:connect(Touched)
function onTouched(hit)
    script.Parent.Parent.Door.Transparency= 1 -- an invisible door
    script.Parent.Parent.Door.CanCollide= false -- a walkthroughable door
    wait(3)
    script.Parent.Parent.Door.Transparency= 0.3  -- a partially visible door 
    script.Parent.Parent.Door.CanCollide= true -- a door you can't walk through anymore
end
script.Parent.Touched:connect(onTouched)

I have roblox 2014, but the tutorial I watched was 2013, can you please tell me why It won't work?

2 answers

Log in to vote
2
Answered by
Redbullusa 1580 Moderation Voter
9 years ago

Remove the first line. That first connection line isn't necessary (Unless if you're calling another function by the name of "Touched").

0
Oh/ foxawesome25 0 — 9y
0
Plus, that argument "hit" isn't necessary also, since you're not using the argument at all (but you can leave it there if you want to). Redbullusa 1580 — 9y
Ad
Log in to vote
-6
Answered by
Maliux 0
9 years ago

I believe its on line 2 that you forgot the .Parent it should be ( I may be wrong, but give it a shot )

function onTouched(hit.Parent)
0
I dont see anything wrong with the other parts of the script though. Maliux 0 — 9y
1
This is wrong; it won't compile, and wouldn't make sense (parameters are what goes *in*, what would it mean to pass in `hit.Parent` if `hit` isn't defined? BlueTaslem 18071 — 9y

Answer this question