Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

i am making a game in roblox with my friends but we are stuck on something?

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! :(

2 comments

0

first off, you might wanna write the entire name of that s script since tripple s refers to the nazis

2

No, SS refers to them. SSS stands for ServerScriptService

3 answers

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.