I'm asking the door to open for me, and it won't, and I have no clue why.
Could somebody please change the script so that it's either more efficient or actually works?
Thanks!
function onKeyDown(key) key = key:lower() if key == "e" then t.BodyVelocity.velocity = Vector3.new(3, 0, 0) wait (3) t.BodyVelocity.velocity = Vector3.new(-3, 0, 0) end end t.KeyDown:connect(onKeyDown)
(Is this right?)
Did you define mouse? It seems like t and your mouse are the same, but it aslo seems like t is the door. Could you show the t varible? Second, instead of using key:lower() you can just use if key == "e" or "E". Lastly, you can use context action service so that you can only open the door when you've touched a brick that's near it.
Here's a more efficient script of this using the link above. To use this make a part thats in front of you door. Make it invisible and non collideable but anchored. Name it DoorRange. Resize it however you like.
DoorRange = game.Workspace.DoorRange --A brick near your door that allows you to open it if you're inside of it. CAS = game:GetService("ContextActionService") function onKeyDown(key) t.BodyVelocity.velocity = Vector3.new(3, 0, 0) wait (3) t.BodyVelocity.velocity = Vector3.new(-3, 0, 0) end end DoorRange.Touched:connect(function(part) if part and part.Parent == player.Character then CAS:BindActionToInputTypes("CASNameHere", onKeyDown, true, "e") end end) DoorRange.TouchEnded:connect(function(part) if part and part.Parent == player.Character then CAS:UnbindAction("CASNameHere") end end)