【问题标题】:fix error attempt to perform arithmetic (add) on string修复错误尝试对字符串执行算术(添加)
【发布时间】:2020-12-20 03:39:35
【问题描述】:
if (hit.Name == "Base") then return end
   hit:BreakJoints()
   if (hit.Anchored == true) then hit.Anchored = false end
   wait(.5)
   for i=1, 10 do
        hit.Transparency = hit.Transparency + 0.1
        wait(0.2)
    end
    print("removing" + hit:GetFullName()) <---- here
    hit:remove()
end
connection = script.Parent.Touched:connect(onTouched)

但我在第 10 行得到“尝试对字符串错误执行算术(加法)”,请问您能解决这个错误吗?

【问题讨论】:

  • 请阅读 Lua 手册

标签: lua roblox


【解决方案1】:

如果hit:GetFullName() 返回一个string,在Lua 中,我们使用两个点.. 连接两个字符串而不是加号+

print("removing " .. hit:GetFullName())

【讨论】:

    猜你喜欢
    • 2017-04-06
    • 2014-02-17
    • 1970-01-01
    • 2020-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-27
    • 2017-01-10
    相关资源
    最近更新 更多