Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Disable KeyPress on touch(brick)?

I am finding a few bugs in my game I am trying to get rid of. Is there a way to disable keypress(C) on touch(brick)?

For Example

local key =  Enum.KeyCode.C
-----------------------------------------------
function onTouched(part) 
	if input.KeyCode == Enum.KeyCode.C then
 		key = false
	end
end
script.Parent.Touched:connect(onTouched) 

Any help?

Also tell me where to put the script;-;

2 answers

✓ Accepted answer
local canPress = true
-----------------------------------------------
function onTouched(part) 
    if input.KeyCode == Enum.KeyCode.C and canPress == true then
        canPress = false
end
end
script.Parent.Touched:connect(onTouched) 

This make's it so when touched, the player cannot press C to active the rest of the script, due to the boolValue set to False.

If it doesn't work, please let me know

6 comments

0

What script?

0

It didnt work. I don't know where to put the script, if it is a local / module / regular script, or where to put it. Where do I use the boolValue?!?!?

0

I would put this in a Local Script & you already made a variable containing a True/False Value, so there's no need to make a seperarte boolValue

0

still doesn't work...here is the script i'm using - https://codeshare.io/5z3DXb try the link. I might accept your answer because, you were trying to help me.

0

Hmmm, if you could shorten the scirpt to only the part that needs fixing, that would help very much

0

The parts that need fixing is everything...mostly.

Where is this "input" variable coming from on line 4? You can't get user input from the server,

This discussion is preserved as it was. New answers, comments, and votes are closed.