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

Choose Your Keys?

Asked by
xp3000 0
9 years ago

I know about KeyDowns.

function onKeyDown(Key) key = key: lower() if key == "c" then

But how would you make it so players can enter a key from a GUI, and then that'll be the key for the function?

1
Take a closer look at your code. TheeDeathCaster 2368 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

I don't think you really know what you're talking about.. But I'll explain to you the functions capability..

Player = game.Players.LocalPlayer -- Up to the player to trigger
mouse = Player:GetMouse() -- Finding the players mouse.
function onKeyDown(Key) -- onKeyDown could be named anything... It's a function
key = key:lower() -- Defining the key
if key == "c" then -- making a statement

end -- where the function ends

I believe this should be a localscript inside of starterGUI.. Under the statement you can insert anything you want if you wanted to destroy the parent you'd do

script.Parent:Destroy()

And what that does is remove it from your sight. It will happen when you press "c". Now you should know what a function is. You can't necessarily change a script with another script. But what you can do is store a value inside of the player that will change when the GUI is pressed, so you can change the key. Make a statement, then compare it to the value and connect it!

0
What I mean is TexBox input. 27 values (one for each letter) feels weird. I might even need to make more for the symbols. xp3000 0 — 9y
0
Can't I say something like "key == (script.Parent.PlayerGUI.KeyChoice.Text)"? xp3000 0 — 9y
Ad

Answer this question