Debounce 不是文件夹的有效成员

Debounce is not a valid member of Folder

好的,我从教程中得到了这个脚本,这就是我为脚本 Remotes 输入的内容

local replicatedStorage = game:GetService("ReplicatedStorage")
local remoteData = game:GetService("ServerStorage"):WaitForChild("RemoteData")

local cooldown = 1

replicatedStorage.Remotes.Lift.OnServerEvent:Connect(function(player)
    print("event launched")
    if not remoteData:FindFirstChild(player.Name) then return "NoFolder" end
    local debounce = remoteData[player.Name].Debounce
    if not debounce then
        debounce.Value = true
        player.leaderstats.Power.Value = player.leaderstats.Power.Value + 5 * (player.leaderstats.Prestiges.Value + 1)
        wait(cooldown)
        debounce.Value = false
    end
end)

但我似乎得到了错误

Debounce 不是文件夹“ServerStorage.RemoteData.OmegaHero2010”的有效成员

这里有一些其他脚本

统计数据

local serverStorage = game:GetService("ServerStorage")

game.Players.PlayerAdded:Connect(function(player)

    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local power = Instance.new("NumberValue")
    power.Name = "Power"
    power.Parent = leaderstats

    local prestige = Instance.new("NumberValue")
    prestige.Name = "Prestiges"
    prestige.Parent = leaderstats


    local dataFolder = Instance.new("Folder")
    dataFolder.Name = player.Name
    dataFolder.Parent = serverStorage.RemoteData

    local debounce = Instance.new("BoolValue")
    debounce.Parent = dataFolder

end)

模块

local module = {}
local replicatedStorage = game:GetService("ReplicatedStorage")

function module.Lift()
    replicatedStorage.Remotes.Lift:FireServer()
end

return module

本地脚本

local module = require(script.Parent:WaitForChild("ModuleScript"))
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
        
script.Parent.Activated:Connect(function()
    module.Lift()
end)

这里有什么问题?

local debounce = remoteData[player.Name].Debounce 行未能找到名为“Debounce”的子项。

那么,看看您是如何在 ServerScriptService 中创建 BoolValue 的:

local debounce = Instance.new("BoolValue")
debounce.Parent = dataFolder

您从未设置 Name 属性。所以播放器文件夹中有一个 BoolValue,但它被命名为“BoolValue”,而不是“Debounce”。要修复您的错误,只需添加行以设置名称。

debounce.Name = "Debounce"