I am trying to make this script change a value when "Q" has been pressed down. Here is the script:
01 | function onKeyPress(inputObject, gameProcessedEvent) |
02 | if inputObject.KeyCode = = Enum.KeyCode.Q then |
03 | local Place = true |
04 | if Place then |
05 | game.Players.LocalPlayer.PlaceMode.Value = false |
06 | Place = false |
07 | if not Place then |
08 | game.Players.LocalPlayer.PlaceMode.Value = true |
09 | end |
10 | end |
11 | end |
12 | end |
13 |
14 | game:GetService( "UserInputService" ).InputBegan:connect(onKeyPress) |
The reason this isn't working properly is because you are setting the value of place down to true every time the function runs
01 | local Place = true |
02 | function onKeyPress(inputObject, gameProcessedEvent) |
03 | if inputObject.KeyCode = = Enum.KeyCode.Q then |
04 | if Place = = true then Place = false |
05 | game.Players.LocalPlayer.PlaceMode.Value = false |
06 | elseif Place = = false then place = true |
07 | game.Players.LocalPlayer.PlaceMode.Value = true |
08 | end |
09 | end |
10 | end |
11 |
12 | game:GetService( "UserInputService" ).InputBegan:connect(onKeyPress) |
Also your not using elseif