So uh, I've been trying to make this script work for some time now with the UserInputService yet I still can't manage to find the solution. I am fairly new to this, so help would be appreciated.
local Player = game.Players.LocalPlayer local anim1 = Instance.new("Animation") anim1.AnimationId = "http://roblox.com/Assets?ID=2294643345" UIS = game:GetService("UserInputService") UIS.InputBegan:connect(function(key) if key.KeyCode == Enum.KeyCode.Q then print("Pressed!") local Fire1 = Instance.new("Fire", Player.Character.LeftHand) Fire1.Color = Color3.new(236, 139, 70) Fire1.SecondaryColor = Color3.new(255, 0, 0) Fire1.Heat = -20 Fire1.Size = 4 local Fire2 = Instance.new("Fire", Player.Character.RightHand) Fire2.Color = Color3.new(236, 139, 70) Fire2.SecondaryColor = Color3.new(255, 0, 0) Fire2.Heat = -20 Fire2.Size = 4 local animation1 = Player.Character.Humanoid:LoadAnimation(anim1) animation1:Play() wait(3) Fire1:destroy() Fire2:destroy() end end)
I am pretty sure the script doesn't go past the
function onKeyPress(inputObject, gameprocessed) if inputObject.KeyCode == Enum.KeyCode.Q then
part.
Thank you.
Not sure if you read my comment already, but as i said, putting a localscript in workspace wont work, you have to put it in starterplayerscripts, i just tried it and it printed out "pressed" so its working
This is what I use in my games.
game:GetService("UserInputService").InputBegan:Connect(function(input,event) if input.KeyCode == Enum.KeyCode.Q then -- [code] end end)
Make sure you use this in a local script!