Help with keycard door script. (With CFrame)

I make a part, name it “door” Anchor it, un weld it. Make a tool called Keycard then I enter this script:
script.Parent.Touched:Connect(function(hit()
if hit.Name == “Keycard” then
local goal = {}
goal.Position = door.Position + Vector3.new(0,6,0)
local Info = TweenInfo.new(1)
local tween = TweenService:Create(door, info, goal)
tween:Play()
wait(7)
local goal = {}
goal.Position = door.Position + Vector3.new(0,0,0)
local Info = TweenInfo.new(1)
local tween = TweenService:Create(door, info, goal)
tween:Play()
end
end)
end)

Is there anything wrong with this script? If so, can you help me?

You’re supposed to tell us :sweat_smile: Tell us how it’s not working, and if you get errors in the output window.

There is this image

So I could be wrong however I believe your problem may be the ( in the Connect(function(hit() part. Below is what your script looks like:

  script.Parent.Touched:Connect(function(hit()    --Extra ( here
  end)

It does not need the extra opening bracket

script.Parent.Touched:Connect(function(hit)	--Removed Opening Bracket
end)

Hopefully this fixes your problem :slightly_smiling_face:

Good Luck with your project.

1 Like

Wait, oh yeah, been awhile since I did a keycard door. (I mean without the CFrame)

1 Like