尝试越过元方法/C调用边界,当使用wait时不能恢复非挂起协程在ROBLOX STUDIO中 (00.1)

这是我的代码

-- 由supermarioclub231 制作并且被称为 marioroblox102 的人编写的脚本,特别感谢jacko提供的一些脚本

-- idk
-- 玩家
local plr = game.Players:CreateLocalPlayer(0)
game:GetService("Visit")
game:GetService("RunService"):run()
plr:LoadCharacter()

-- 必须这样做,以便每次不生成相同的数字

math.random(); math.random(); math.random()

digits = 4 -- 玩家名称末尾添加数字的次数

prefix = "NoName "
suffix = "" -- 不想在这里输入任何内容,数字将在此处添加!

for i=1, digits do
    suffix = suffix .. math.random(1,9)
    i = i + 1;
end

plr.Name = prefix .. suffix

-- shopium献给你...

shirt = Instance.new("Shirt", plr)
pants = Instance.new("Pants", plr)
shirt.ShirtTemplate = "rbxasset://shirts/jared.png"
pants.PantsTemplate = "rbxasset://pants/jeans.png"

while true do
    wait (0.001)
    if plr.Character.Humanoid.Health <= 0 then
        wait(5)
        plr:LoadCharacter(true)
    elseif plr.Character.Parent  == nil then
      wait(5)
      plr:LoadCharacter(true)
    end
end

每次运行代码都会得到以下错误:

1

第39行是wait(000.1), 为什么不起作用? 它应该永远执行某些操作, 像循环一样,但它给了我一个错误

点赞
用户16323667
用户16323667

首先,在开头你不需要使用math.random()三次,以便每次都生成不同的脚本,因为这不是它的工作方式。它将在指定的范围内生成一个随机数,每次都可能是相同的数字,但这就是为什么它被称为math.random()。我也在努力修复你的其余脚本,只是想告诉你这一点。另外,只需使用ROBLOX Health Changed Event,该事件的wiki链接在这里。

2021-06-26 19:34:47