Roblox Studio中的Inf timestop glitch(ServerScriptService.TheWorldServer.TS:35: attempt to index nil with 'Name')

我不断收到这个错误。该错误仅适用于此代码。它导致时间停止无限期。有人知道如何解决吗?错误是ServerScriptService.TheWorldServer.TS:35:尝试索引 nil with 'Name',任何帮助都非常感激。

我不知道如何解决这个问题,所以帮助非常有用。

local music = game.Workspace.BackgroundMusic
local model = game.ReplicatedStorage.Stand
local InUse = game.ReplicatedStorage.InUse
local bacon = {}
local G = {}

model.BaconTimeStop.OnServerEvent:Connect(function(player)
    local find = workspace:GetDescendants()
    if InUse.Value == false then
        InUse.Value = true

        local Sound = script.TSSound:Clone()
        Sound.Parent = workspace
        Sound:Play()
        music:Pause()
        wait(1.8)

        local TweenService = game:GetService("TweenService")

        local part = game.Lighting.ColorCorrection

        local goal = {}
        goal.Contrast = -2

        local tweenInfo = TweenInfo.new(0.2)

        local tween = TweenService:Create(part, tweenInfo, goal)

        tween:Play()
        for i=1, #find do
            local That = find[i]
            if That:IsA("Part") or That:IsA("MeshPart") then
                if That.Anchored == false and That.Parent.Name ~= player.Name and That.Parent.Parent.Name ~= player.Name and That.Name ~= "Baseplate" and not That.Parent:IsA("Accessory") then
                    That.Anchored = true
                    table.insert(bacon, That)
                end
            end
            if That:IsA("ParticleEmitter") then
                That.TimeScale = 0
                table.insert(G, That)
            end
        end
        wait(3)
        InUse.Value = false
        local TweenService = game:GetService("TweenService")

        local part = game.Lighting.ColorCorrection

        local goal = {}
        goal.Contrast = 0

        local tweenInfo = TweenInfo.new(0.2)

        local tween = TweenService:Create(part, tweenInfo, goal)

        music:Resume()

        tween:Play()
        for i=1, #bacon do
            bacon[i].Anchored = false
        end
        table.clear(bacon)
        for i=1, #G do
            G[i].TimeScale = 1
        end
        table.clear(G)
    end
end)
点赞
用户2858170
用户2858170

错误信息告诉你需要知道的一切。

ServerScriptService.TheWorldServer.TS:35: 尝试使用“Name”索引nil

这是第35行:

if That.Anchored == false
   and That.Parent.Name ~= player.Name
   and That.Parent.Parent.Name ~= player.Name
   and That.Name ~= "Baseplate"
   and not That.Parent:IsA("Accessory") then

.Name(索引运算符.)中索引多个变量。

其中一个值是 nil

That 不能是 nil,因为这会在更早的时候引起错误。

打印 playerThat.ParentThat.Parent.Parent,找出其中哪一个是 nil。然后找出原因并修复它。我们无法在这里帮助您。如果它是一个有效的状态,只需避免索引或将其替换为某些默认值。

2021-06-17 10:54:51