You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Roblox Studio角色传送脚本报错:无法识别Humanoid及空值索引

Roblox角色传送脚本报错排查求助

尝试将所有角色传送到指定点位,测试时曾将脚本放置在ServerScriptService与WorkSpace中,也尝试过多种代码写法,但始终收到“Humanoid is not a valid part of (角色名)”和“attempted to index nil”错误。以下是当前脚本及报错信息,恳请协助解决:

spawnMH = Vector3.new(0.578, 42.203, 24.559)
spawnBattle = {Vector3.new(-403.386, -1.739, 1098.992), Vector3.new(855.657, 6.303, 1177.902), Vector3.new(1114.807, 3.436, -243.573), Vector3.new(956.57, 19.462, 912.349), Vector3.new(-990.968, 3.027, 356.449), Vector3.new(-1152.185, 52.029, 781.85)}

function InitTeleportDay()  
    for _, player in pairs(game.Players:GetPlayers()) do
        workspace:WaitForChild(player.Name)
        local character = player.Character or player.CharacterAdded:Wait()
        local humanoid = character:WaitForChild("Humanoid")
        humanoid:MoveTo(spawnMH)
    end
end

function InitTeleportNight()
    for _, player in pairs(game.Players:GetPlayers()) do
        workspace:WaitForChild(player.Name)
        local character = player.Character or player.CharacterAdded:Wait() 
        local humanoid = character:WaitForChild("Humanoid")
        humanoid:MoveTo(spawnBattle.get(Random.new(5))) 
    end
end

while true do
    wait(1*60)
    InitTeleportDay()
    wait(1*60)
    InitTeleportNight()
end

报错信息:

ServerScriptService.TeleportFunc:22: attempt to call a nil value - server - TeleportFunc:22
Humanoid is not a valid member of Model "maxeagleman" - Client

试过character:MoveTo()、character.Humanoid:MoveTo()等多种写法均无效,仍在调试中,若找到解决方案会更新。

内容的提问来源于stack exchange,提问作者Rauchbier

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 18:23:09