How do I let players be able to bind a certain skill to a certain key?
I'm currently working on an RPG with some skills and I want to make it so that players can bind skills to their preferred keys, however, I can't think of a way to make that happen. Here's what I have tried:
02 | local player = script.Parent.Parent |
03 | local character = player.Character |
04 | local uis = game:GetService( "UserInputService" ) |
05 | local pkey = script.PressedKey.Value |
06 | local jutsulife = script.JutsuLife.Value |
07 | local cooldown = script.Cooldown.Value |
09 | uis.InputBegan:connect( function (input, gpe) |
11 | if input.UserInputType = = Enum.UserInputType.Keyboard then |
12 | if input.KeyCode = = pkey then |
15 | local animTrack = character.Humanoid:LoadAnimation(script.HandSigns) |
17 | local signsound = Instance.new( "Sound" , character.Head) |
18 | signsound.PlayOnDestroy = true |
24 | local jutsusound = Instance.new( "Sound" , character.Head) |
25 | jutsusound.PlayOnDestroy = true |
31 | local firesound = Instance.new( "Sound" , character.Head) |
32 | firesound.PlayOnDestroy = true |
36 | game:GetService( "Chat" ):Chat(character.Head, "Katon: Gokakyu no Jutsu!" , "Red" ) |
37 | local x = Instance.new( "Part" ) |
38 | x.BrickColor = BrickColor.new( "Really red" ) |
39 | x.Size = Vector 3. new( 10 , 10 , 10 ) |
40 | x.TopSurface = "Smooth" |
41 | x.BottomSurface = "Smooth" |
46 | local flame = Instance.new( "ParticleEmitter" , x) |
47 | flame.EmissionDirection = "Back" |
48 | flame.Speed = NumberRange.new( 2.5 ) |
49 | flame.Size = NumberSequence.new( 2 ) |
51 | flame.Lifetime = NumberRange.new( 1 ) |
52 | flame.LightEmission = 0.5 |
54 | flame.Color = ColorSequence.new(Color 3. new( 1 , 0.6 , 0 ), Color 3. new( 1 , 0.7 , 0 )) |
55 | flame.LockedToPart = false |
57 | local damage = script.damage:clone() |
59 | local y = Instance.new( "BodyVelocity" ) |
60 | y.maxForce = Vector 3. new( math.huge , math.huge , math.huge ) |
61 | y.velocity = character.Torso.CFrame.lookVector* 45 |
64 | x.CFrame = character.Head.CFrame*CFrame.new( 0 , 0 , - 1 ) |
65 | damage.Disabled = false |
66 | game.Debris:AddItem(x, jutsulife) |
The script.PressedKey
is a StringValue with the value "Enum.KeyCode.R", but when I press the 'R' button it doesn't work.