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:
local enabled = true local player = script.Parent.Parent local character = player.Character local uis = game:GetService("UserInputService") local pkey = script.PressedKey.Value local jutsulife = script.JutsuLife.Value local cooldown = script.Cooldown.Value uis.InputBegan:connect(function(input, gpe) if not gpe then if input.UserInputType == Enum.UserInputType.Keyboard then if input.KeyCode == pkey then if enabled then enabled = false local animTrack = character.Humanoid:LoadAnimation(script.HandSigns) animTrack:Play() local signsound = Instance.new("Sound", character.Head) signsound.PlayOnDestroy = true signsound.SoundId = "http://www.roblox.com/asset/?id=245030009" signsound.Volume = 1 signsound.Pitch = 1.5 signsound:Destroy() wait(1) local jutsusound = Instance.new("Sound", character.Head) jutsusound.PlayOnDestroy = true jutsusound.SoundId = "http://www.roblox.com/asset/?id=147722098" jutsusound.Volume = 1 jutsusound:Destroy() wait(0.5) animTrack:Stop() local firesound = Instance.new("Sound", character.Head) firesound.PlayOnDestroy = true firesound.SoundId = "http://www.roblox.com/asset/?id=245029978" firesound.Volume = 1 firesound:Destroy() game:GetService("Chat"):Chat(character.Head, "Katon: Gokakyu no Jutsu!", "Red") local x = Instance.new("Part") x.BrickColor = BrickColor.new("Really red") x.Size = Vector3.new(10, 10, 10) x.TopSurface = "Smooth" x.BottomSurface = "Smooth" x.Shape = "Ball" x.Name = player.Name x.CanCollide = false x.Transparency = 0.75 local flame = Instance.new("ParticleEmitter", x) flame.EmissionDirection = "Back" flame.Speed = NumberRange.new(2.5) flame.Size = NumberSequence.new(2) flame.Rate = 1000 flame.Lifetime = NumberRange.new(1) flame.LightEmission = 0.5 flame.Texture = "http://www.roblox.com/asset/?id=288049555" flame.Color = ColorSequence.new(Color3.new(1, 0.6, 0), Color3.new(1, 0.7, 0)) flame.LockedToPart = false flame.Name = "Flames" local damage = script.damage:clone() damage.Parent = x local y = Instance.new("BodyVelocity") y.maxForce = Vector3.new(math.huge, math.huge, math.huge) y.velocity = character.Torso.CFrame.lookVector*45 x.Parent = workspace y.Parent = x x.CFrame = character.Head.CFrame*CFrame.new(0, 0, -1) damage.Disabled = false game.Debris:AddItem(x, jutsulife) wait(cooldown) enabled = true end end end end end)
The script.PressedKey
is a StringValue with the value "Enum.KeyCode.R", but when I press the 'R' button it doesn't work.