好吧,首先,scriptinghelpers.org 是专门为 Roblox 创建的,类似于 stackoverflow 的服务,我建议下一次,你在那里问,现在开始吧;
-- If you have further problems, My Roblox username is 'ZeroBits' (REMOVE THIS LINE)
DEBUG = true -- Debug Print, so you can disable it when you're done.
local function print_D(t)
if DEBUG == true then warn(t) end end
print_D("DEBUG MODE, Switch Debug Value to False when finished")
local Humanoid = script.Parent:FindFirstChild("Zombie") -- We'll use FindFirstChild() here
--if not Humanoid then -- Uncomment this statement if you want it to affect objects named Humanoid as well
-- Humanoid = script.Parent:FindFirstChild("Humanoid")
--end
function HumanoidKilled() -- Renamed the function to be a little less cringeworthy
print_D("1") -- switched these print statements with the Print_D() function
local tag = Humanoid:FindFirstChild("creator") -- Capitalized the first letter in FindFirstChild()
print_D("2")
if not tag then
warn("No Tag Found check Humanoid and weapon script") --if this prints, there's either no tag, or a serious problem, and you should check the humanoid object for a tag, or make sure the weapons you use actually generate tags.
else -- changed 'if tag ~= nil then' to 'if not tag then 'do stuff' else' to simplify the code, and add an else statement early on.
print_D("3")
if tag.Value then -- removed '~= nil' because it's just useless clutter
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() -- switched remove() to Destroy(), remove() is deprecated
end
end
end
end
Humanoid.Died:connect(HumanoidKilled)
这修复了脚本中的所有问题,并提高了效率。如果仍然存在问题,则可能是在标签创建脚本中,标签未存储在人形机器人中,或者标签未命名为“创建者”
另外,我将 print 语句切换到 print_D 函数,它使用 warn() 而不是 print() 几乎没有区别,只是调试文本在控制台中将显示为黄色,而不是白色。
脚本正在用于名为“ROBLOX”的游戏。谢谢!
是针对 Roblox 上的游戏,不是 Roblox 游戏,你说的就像是在说;我为 Source Engine 制作了这个模组,而你实际上为半条命 2 制作了模组