请问active和debounce是什么?

我不知道active和debounce是什么,我的意思是它们在做什么,为什么它们在那里?能有人解释一下吗? 好的,这是代码:


local debounce = false
local active = false

UIS.InputBegan:Connect(function(input,isTyping)
    if isTyping then
        return
    elseif input.KeyCode == Enum.KeyCode.E then
        if debounce == false and active == false then
            debounce = true

            blabla:FireServer(active)
        end
    end
end)
点赞
用户13819852
用户13819852

本地防抖变量是一个布尔值,用于标记服务器事件是否已经触发/正在触发(可以通过“if debounce == false”字段看到)。如果玩家按下 E 键,则事件会触发并将 debounce 的值设置为 false,因此该脚本不会再次触发该事件,直到您/代码将其设置为 true。 顺便说一下,您可以在 Roblox 的网站上查看有关 Lua 类型的所有信息,在这里,您可以找到有关布尔值和变量的文章: https://developer.roblox.com/en-us/articles/Boolean

活跃的值用于由服务器创建的远程事件(服务器通过远程事件获得活动变量以进行服务器上的函数)。

2020-09-03 18:36:05