(resolved) Key card door help

I get an error whith this code:

script.Parent.Touched:Connect(function(hit)
if hit.Parent.Name == script.Parent.KeyCardValue.Value then
script.Parent.Transparency = .5
script.Parent.CanCollide = false
wait(1)
script.Parent.Transparency = 0
script.Parent.CanCollide = true
end)

Error:
[21:25:14.438 - Workspace.Part.Script:8: Expected identifier when parsing expression, got β€˜)’

1 Like

Your if statement has no end.
Also, please format your code properly using
```
– your code
```
:smiley:

1 Like

Its just a simple typo issue, I don’t think you should post these threads without trying to solve the problem yourself a bit:

script.Parent.Touched:Connect(function(hit)
   if hit.Parent.Name == script.Parent.KeyCardValue.Value then
       script.Parent.Transparency = .5
       script.Parent.CanCollide = false
       wait(1)
       script.Parent.Transparency = 0
       script.Parent.CanCollide = true
   end
end)

You had forgot an end for closing the If statement, also please format your code, most error fixes come up easily if you format your code.

2 Likes

Thanks, I tried but am VERY new to scripting.

1 Like

Will do next time, didnt know about that.

Not a problem, just make sure you do it from next time.

1 Like