of     1   

iamarobloxfan
#221314123Friday, July 14, 2017 5:14 PM GMT

I am creating a door script, where whenever you press 'E', the door will open. However, I am having a problem where it will only register you pressing the 'E' key whenever you have it down right as you touch the invisible block to open the door. Here is my code: local deb = false function touch(hit) if deb == false then deb = true local UIP = game:GetService ("UserInputService") if UIP:IsKeyDown(101) then if game.Workspace.Door1.CanCollide == true then game.Workspace.Door1.CanCollide = false elseif game.Workspace.Door1.CanCollide == false then game.Workspace.Door1.CanCollide = true end end wait(1) deb = false end end script.Parent.Touched:connect(touch) How do I make it so it will register the E key always while you're inside the block?
iamarobloxfan
#221314903Friday, July 14, 2017 5:24 PM GMT

bUmP
iiNemo
#221317680Friday, July 14, 2017 6:01 PM GMT

game:GetService('UserInputService'):Connect(function(Input) if Input.KeyCode == Enum.KeyCode.E then end end)
iamarobloxfan
#221334051Friday, July 14, 2017 9:36 PM GMT

Nope, I changed the capitalization of Connect and it still didn't work. Most likely because a service can't be in the connection of a function, that needs to be touch.
LeafDoode
#221334389Friday, July 14, 2017 9:40 PM GMT

try UIP:IsKeyDown(Enum.KeyCode.E)
LeafDoode
#221334469Friday, July 14, 2017 9:42 PM GMT

@iiNemo "game:GetService("UserInputService"):connect(function(Input)" LOL?!
iamarobloxfan
#221334593Friday, July 14, 2017 9:43 PM GMT

@Leaf It works, but only when you first come in contact with the block. If I stand inside the block and press E, it doesn't work.
iamarobloxfan
#221334617Friday, July 14, 2017 9:44 PM GMT

and yeah, the function idea was terrible lol
LeafDoode
#221334652Friday, July 14, 2017 9:44 PM GMT

then you need a variable
iamarobloxfan
#221334719Friday, July 14, 2017 9:45 PM GMT

As in a variable for the UIP? Or a variable to figure out if the player is still touching the block?
LeafDoode
#221334808Friday, July 14, 2017 9:46 PM GMT

UIS = game:GetService("UserInputService") if UIS:IsKeyDown(Enum.KeyCode.E) then pressed = true end block.Touched:connect(function(hit) touch = true end) if pressed = true and touch = true then --code end
LeafDoode
#221334869Friday, July 14, 2017 9:47 PM GMT

if pressed == true and touched == true then* --code end
iamarobloxfan
#221336099Friday, July 14, 2017 10:01 PM GMT

Yeah, I've been messing with it for the past minutes, but it seems like the keycode thing isn't firing. The touch is just fine.
iamarobloxfan
#221337898Friday, July 14, 2017 10:16 PM GMT

bump
yin_yang
#221339568Friday, July 14, 2017 10:28 PM GMT

localscript local self = game.Players.LocalPlayer local pressed local ####### ##### ### = game:GetService("UserInputService") local door = workspace.door1 local db = false function thisdoorthing() if pressed and touched then -- code() end end uis.InputBegan:connect(function(thisinputthing) if thisinputthing.KeyCode == Enum.KeyCode.E then thisdoorthing() -- since the input is what should trigger the door, the function lies here end end) door.Touched:connect(function(hit) if not db then (db == true) local humanoid = hit.Parent:WaitForChild("Humanoid") if humanoid then touched = true end end db = false end) a mistake i saw in your code is that you have not applied a "verifier" to check whether or not an actual player is touching the door. without this humanoid checker the door can be opened at any time as long as there's something touching it.
yin_yang
#221339863Friday, July 14, 2017 10:30 PM GMT

(pathetic filter) localscript local self = game.Players.LocalPlayer local pressed local tch local inputserv = game:GetService("UserInputService") local door = workspace.door1 local db = false function thisdoorthing() if pressed and tch then -- code() end end inputserv.InputBegan:connect(function(thisinputthing) if thisinputthing.KeyCode == Enum.KeyCode.E then thisdoorthing() -- since the input is what should trigger the door, the function lies here end end) door.Touched:connect(function(hit) if not db then (db == true) local humanoid = hit.Parent:WaitForChild("Humanoid") if humanoid then tch = true end end db = false end) a mistake i saw in your code is that you have not applied a "verifier" to check whether or not an actual player is touching the door. without this humanoid checker the door can be opened at any time as long as there's something touching it.
iamarobloxfan
#221342293Friday, July 14, 2017 10:46 PM GMT

Do I need to have some setting on for this to work? I put a little print thing in to verify if it worked(I fixed one error I noticed) and it just isn't working. I ran it in a server too, and it still didn't work. I'm starting to wonder if I need to turn on a setting for this to work, and yes, this was in a localscript.
iamarobloxfan
#221345361Friday, July 14, 2017 11:08 PM GMT

bump..
iamarobloxfan
#221346983Friday, July 14, 2017 11:21 PM GMT

Ugh, I guess I'll have to do something different for the door then.
BaiYuni
#221349071Friday, July 14, 2017 11:39 PM GMT

Here's an idea. Have 2 scripts: 1 that does the UserInputService (the local script), and another Script that does the Touched and TouchEnded event (a regular ServerScript) When the object is touched, the localscript will have the 'Disabled' property as false and when the TouchEnded event fires, the 'Disabled' property will be set to true.

    of     1