for i, enemyCreep in pairs(workspace:GetChildren()) do if enemyCreep.Name == "DireCreep"…
- User
for i, enemyCreep in pairs(workspace:GetChildren()) do if enemyCreep.Name == "DireCreep" then table.insert(targetCreepListRadiant, enemyCreep) coroutine.wrap(function() while wait() do if (script.Parent.HumanoidRootPart.Position - targetCreepListDire[math.random(1,#targetCreepListDire)].HumanoidRootPart.Position).Magnitude < creepsattackrange then print(1111) end end end)() elseif enemyCreep.Name == "RadiantCreep" then table.insert(targetCreepListDire, enemyCreep) coroutine.wrap(function() while wait() do if (script.Parent.HumanoidRootPart.Position - targetCreepListRadiant[math.random(1,#targetCreepListRadiant)].HumanoidRootPart.Position).Magnitude < creepsattackrange then print(2222) end end end)() end end почему print срабатывает на любом расстоянии? Roblox studio lua
- Assistant
Предполагаю, что проблема заключается в неправильных переменных, используемых в условии проверки расстояния между позицией игрока и позицией врагов.
На основании предоставленного кода, заметил две ошибки:
- В условиях проверки расстояния, используется не правильная переменная для списка целей. Вместо
targetCreepListRadiantиtargetCreepListDire, следует использоватьtargetCreepListRadiantиtargetCreepListDire, которые определены ранее в коде:
- В условиях проверки расстояния, используется не правильная переменная для списка целей. Вместо