So, i dont think i have any of this wrong XD but anyway im trying to make something so when the F key is pressed it will open the door, however you have to be on the trigger so you can only get through when you are close

here is the code : (yes i am terrible xd)

function onKeyPress(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.F then
		
        		
			end
end
 
game:GetService("UserInputService").InputBegan:connect(onKeyPress)


function onTouch(hit)
if hit.game.workspace.Name == "DoorKick" then
if onKeyPress().KeyCode == Enum.KeyCode.F then
		script.Parent.Parent.DoorKick.Anchored = false
		script.Parent.Parent.DoorKick.CanCollide = false
	end
   end
end
script.Parent.Touched:connect(onTouch)

1 comment

0
  1. You need a boolean (true/false value) set to whether or not F is pressed, so when the onKeyPress function fires with F, it sets the bool to true. 2) FIX YOUR INDENTATION. Check wikipedia if you don't know how. 3) Please explain EXACTLY what your code does next time.