Essentially what I have been trying to do is displaying 3 numbers in a table called Hector3 in a text box, and whenever you hold A, it adds +1 to the 2nd value.
I’m only going to post a small part of the code since the actual holding down button fully works.
Full Script
local UIS = game:GetService("UserInputService")
local Hector3 = {0, 0, 0}
local TextBoxOne = script.Parent.X
TextBoxOne.Text = tostring(table.unpack(Hector3))
interval = 0.5
local KeyDown = false
local function onInputBegan(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.A then
KeyDown = true
repeat wait()
print("Holding down A")
Hector3[2] = Hector3[2] +1
TextBoxOne.Text = table.unpack(Hector3)
until KeyDown == false
end
end
end
local function onInputEnded(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.A then
KeyDown = false
end
end
end
UIS.InputBegan:Connect(onInputBegan)
UIS.InputEnded:Connect(onInputEnded)
For some reason, absolutely nothing happens and the text just. I have a feeling that the issue is somehwere in the repeat until loop somehwere, just can’t figure out how to fix.