Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Disable KeyPress on touch(brick)?

Asked by
clrik 8
6 years ago

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

Log in to vote
0
Answered by
oSyM8V3N 429 Moderation Voter
6 years ago
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

0
What script? clrik 8 — 6y
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?!?!? clrik 8 — 6y
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 oSyM8V3N 429 — 6y
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. clrik 8 — 6y
View all comments (2 more)
0
Hmmm, if you could shorten the scirpt to only the part that needs fixing, that would help very much oSyM8V3N 429 — 6y
0
The parts that need fixing is everything...mostly. clrik 8 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

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

Answer this question