This is what I have so far in my quest in trying to make this work, all of this part is done in a local script that is inside the player's character.
local flipping = false local player = game.Players.LocalPlayer local character = player.Character local hum = character:FindFirstChild("Humanoid") local UIS = game:GetService("UserInputService") UIS.InputBegan:connect(function(input, event) if event then return end if input.KeyCode == Enum.KeyCode.Q then if not flipping then flipping = tick() else if tick() - flipping < 0.2 then flipping = true --Do Stuff here wait(1) flipping = false else flipping = false end end end end)
I keep getting this error which I don't know if this is contributing to it not working that well, and I don't really understand how I would fix it.
Workspace.MyTradeJustWentViral.StaminaMoves:87: attempt to perform arithmetic on upvalue 'flipping' (a boolean value)
It's not really that accurate at detecting if you actually double tapped the button. Any help on this would be appreciated.
Hi MyTradeJustWentViral,
----------------- Services ---------------------- local players = game:GetService("Players"); local uis = game:GetService("UserInputService"); ----------------- Services ---------------------- ----------------- Initial Variables ---------------------- local player = players.LocalPlayer; local t = 0; -- Start at 0, this will be what records the previous tick. local dif = tick() - t; -- The difference between each click. ----------------- Initial Variables ---------------------- function do_it(key, gp) if key.KeyCode == Enum.KeyCode.Q and not gp then -- Checks if Q was pressed and if the player meant to press it, as in was it pressed while typing or was it just pressed with intention(without typing) dif = tick() - t; -- Updates the difference. if dif < 3 then -- Checks if the difference is less than 3 seconds, so, you need to click a second time within the range of 3 seconds to activate double tap. print("You double tapped."); -- Prints this if you did double tap. t = 0; -- Sets the previous tick to 0 because we're starting a new sequence. return -- returns so that the rest of the function doesn't run, so that the t doesn't become tick() again because we're starting a new sequence. end -- end for if statement to check if the difference is smaller than 3. t = tick(); -- Updates the previous tick with a new tick since the new tick becomes the previous tick. end -- end for if statement to check if Q was pressed and if it was meant to be pressed. end -- end for function. uis.InputBegan:Connect(do_it); -- Connects function to event.
Thanks,
Best regards,
~~ KingLoneCat
local x = Instance.new("BoolValue") x.Parent = script x.Name = "BoolValue" game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.Q then script.BoolValue.Value = true game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent) if script.BoolValue.Value == true then if inputObject.KeyCode == Enum.KeyCode.Q then --stuffs here script:Destroy() end script.BoolValue.Value = false end end) end end)
script is temporary, after detecting 1 double click it will destroy, sorry i can't make any script that will detect double taps, But that's what i did so far