【问题标题】:attempt to yield across metamethod/C-call boundary AND cannot resume non-suspended coroutine in ROBLOX STUDIO when using wait (00.1)尝试跨越元方法/C调用边界并且在使用等待时无法恢复ROBLOX STUDIO中的非暂停协程(00.1)
【发布时间】:2021-09-06 09:49:26
【问题描述】:

这是我的代码

-- Script by supermarioclub231 as known as marioroblox102, and special thanks to jacko for some scripts things

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

-- have to do this so that the same numbers arent generated every time

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

digits = 4 -- the amount of times to add digits to the end of the player name

prefix = "NoName "
suffix = "" -- wouldnt wanna type anything here, the digits will be added here!

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

plr.Name = prefix .. suffix

-- shopium brings to you...

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

每次我运行它,我都会得到这个

第 39 行是 wait(000.1), 为什么它不工作? 它应该永远做某事 像一个循环 但它给了我一个错误

【问题讨论】:

    标签: lua roblox


    【解决方案1】:

    首先你不必在开始时使用 math.random() 三次,所以它不会每次都生成相同的脚本,因为它不是这样工作的,它会在你的范围内生成一个随机数指定每次,并且数字可能每隔一段时间都相同,但这就是为什么它被称为 math.random() 但我也在努力修复你脚本的其余部分,只是想告诉你。也只需使用 ROBLOX Health Changed Event,该事件的 wiki 链接是 here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-05
      • 2021-04-16
      • 1970-01-01
      • 2017-12-06
      • 2018-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多