i am making a game in roblox with my friends but we cant figure out how to make it so that you hit the key "F" and then the value of an intvalue created in a sss script by +1. we have tried many scripts but none have worked! :(
I am writing this script thinking that the IntValue is inside the script
local intVal = script:WaitForChild("Value") --'Value' is the name of your value, you might need to change this game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.F then intVal.Value = intVal.Value + 1 end end)
This is similar to the previous answer, but it is simpler. I hope the fixes your problem
You look for a key using the following:
local UIS = game:GetService("UserInputService") UIS.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.F then value.Value = value.Value + 1 end end
you need userinputservice so
local uis = game:GetService("UserInputService") uis.InputBegan:Connect(function(input,chat)--this checks every time you click down a key for what key it is if input.KeyCode == Enum.KeyCode.F and not chat then--making sure they arent typing anything intvalue.Value = intvalue.Value + 1--just add on the value now end end)