为什么这个脚本不起作用?
2015-4-10 21:44:25
收藏:0
阅读:84
评论:1
以下脚本在 print("2") 和 print("3") 之间断开,因为它找不到变量 "tag"。我该如何修复?
local Humanoid = script.Parent.Zombie -- 或者僵尸或其他
function PwntX_X()
print("1")
local tag = Humanoid:findFirstChild("creator")
print("2")
if tag ~= nil then
print("3")
if tag.Value ~= nil then
print("4")
local Leaderstats = tag.Value:findFirstChild("leaderstats")
print("5")
if Leaderstats ~= nil then
print("6")
Leaderstats.Cash.Value = Leaderstats.Cash.Value + 5
print("7")
wait(0.1)
script:remove()
end
end
end
end
Humanoid.Died:connect(PwntX_X)
我已经有了一个百分之百工作的排行榜脚本。这个脚本被用于一个叫做“ROBLOX”的游戏。谢谢!
点赞
评论区的留言会收到邮件通知哦~
推荐文章
- 如何将两个不同的lua文件合成一个 东西有点长 大佬请耐心看完 我是小白研究几天了都没搞定
- 如何在roblox studio中1:1导入真实世界的地形?
- 求解,lua_resume的第二次调用继续执行协程问题。
- 【上海普陀区】内向猫网络招募【Skynet游戏框架Lua后端程序员】
- SF爱好求教:如何用lua实现游戏内调用数据库函数实现账号密码注册?
- Lua实现网站后台开发
- LUA错误显式返回,社区常见的规约是怎么样的
- lua5.3下载库失败
- 请问如何实现文本框内容和某个网页搜索框内容连接,并把网页输出来的结果反馈到另外一个文本框上
- lua lanes多线程使用
- 一个kv数据库
- openresty 有没有比较轻量的 docker 镜像
- 想问一下,有大佬用过luacurl吗
- 在Lua执行过程中使用Load函数出现问题
- 为什么 neovim 里没有显示一些特殊字符?
- Lua比较两个表的值(不考虑键的顺序)
- 有个lua简单的项目,外包,有意者加微信 liuheng600456详谈,最好在成都
- 如何在 Visual Studio 2022 中运行 Lua 代码?
- addEventListener 返回 nil Lua
- Lua中获取用户配置主目录的跨平台方法
首先,scriptinghelpers.org是针对Roblox的一项类似于stackoverflow的服务。下次我建议你去那里询问问题。现在开始正文:
-- 如果您有进一步的问题,我的Roblox用户名是'ZeroBits'(删除本行) DEBUG = true -- 调试输出,以便在完成后禁用它。 local function print_D(t) if DEBUG == true then warn(t) end end print_D("DEBUG MODE,完成后将调试值更改为False") local Humanoid = script.Parent:FindFirstChild("Zombie") -- 这里我们将使用FindFirstChild() --if not Humanoid then -- 如果要影响名为“Humanoid”的对象,则取消注释此语句 -- Humanoid = script.Parent:FindFirstChild("Humanoid") --end function HumanoidKilled() -- 将函数名称更改为稍微不那么糟心的名称。 print_D("1") -- 使用Print_D()函数与这些打印语句进行切换。 local tag = Humanoid:FindFirstChild("creator") -- 将FindFirstChild()中的第一个字母大写。 print_D("2") if not tag then warn("未找到标签,请检查Humanoid和Weapon脚本") -- 如果打印此内容,要么没有标记,要么存在严重问题,请检查具有标记的人形对象,以确保您使用的武器实际上会生成标记。 else -- 更改'if tag ~= nil then'为'if not tag then 'do stuff' else',以简化代码并尽早添加else语句。 print_D("3") if tag.Value then -- 删除“~= nil”,因为它只是无用的杂质。 print_D("4") local Leaderstats = tag.Value:findFirstChild("leaderstats") print_D("5") if Leaderstats ~= nil then print_D("6") Leaderstats.Cash.Value = Leaderstats.Cash.Value + 5 print_D("7") wait(0.1) script:Destroy() -- 将remove()切换为Destroy(),remove()已不推荐使用。 end end end end Humanoid.Died:connect(HumanoidKilled)这修复了脚本中的所有问题,并使其更加高效。如果仍然存在问题,则可能在标签创建脚本中,标签未存储在人形对象中,或标签未命名为“creator”。
此外,我将打印语句切换为print_D函数,该函数使用warn()而不是print(),几乎没有区别,除了在控制台中,调试文本将变为黄色,而不是白色。
它是用于Roblox上的游戏,而不是称为Roblox的游戏。您说的类似于说; 我为Source Engine制作了此mod,当您实际上为Half-Life 2制作了该mod。