Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I have a KeyCode script with debounce but it dosen't work?

Asked by 5 years ago
Edited 5 years ago

local assetID = 02236125916 local MaxDistance = 25 debounce = false function onKeyPress(inputOject, gameProcessedEvent) if inputObject.Keycode == Enum.KeyCode.R then game:GetService("InsertService"):LoadAsset(02236125916).Parent = game.Workspace.Model if debounce == false then debounce = true if game:GetService("UserInputService").InputEnded then if debounce == false then debounce = true game.Workspace["BB GUI"].BillboardGUI.Enabled = false wait(1) debounce = false end end end end game:GetService("UserInputService").InputBegan:connect(onKeyPress)

I think I might have put the debounce codes in the wrong place, please help!

0
Are you gonna use the 'else' statement or no? If no, or waits? cherrythetree 130 — 5y
0
@cherrythetree Could you post an example. Also if you could add in a part where you can only use the R key from a certain distance that would be nice! CoreMcNugget 15 — 5y
0
InsertService is server-side only. I recommend using a RemoteEvent.! User#19524 175 — 5y
0
Btw, if there is assetId then why are you not using it to line 07? And you forgot local in debounce. And I think I will agree incapaz but InsertService can give assets thought. cherrythetree 130 — 5y
0
If my answer satisfies your question, please accept it. RAYAN1565 691 — 5y

1 answer

Log in to vote
0
Answered by
RAYAN1565 691 Moderation Voter
5 years ago
Edited 5 years ago
local assetID, MaxDistance, debounce = 02236125916, 25, false

function onKeyPress(inputObject, gameProcessedEvent) --You spelled 'inputObject' incorrectly. I fixed it.
    if inputObject.Keycode == Enum.KeyCode.R and debounce == false then 
        debounce = true
        game:GetService("InsertService"):LoadAsset(02236125916).Parent = game.Workspace.Model
        while true do
            wait()
            if game:GetService("UserInputService").InputEnded then
                game.Workspace["BB GUI"].BillboardGUI.Enabled = false
                wait(1)
                break
            end
        end
    end
    debounce = false
end

game:GetService("UserInputService").InputBegan:connect(onKeyPress)
Ad

Answer this question