如何修复EOF附近的最终预期错误

时间:2019-10-20 20:00:51

标签: lua roblox

我在Roblox中赚了一笔用于杀死游戏的现金,但是我想做得更多,并实施一个脚本,当一个玩家拥有游戏通行证时,该玩家将比其他普通玩家获得更多的现金。

这是在Roblox中用于大逃杀风格的游戏,当我进行游戏测试时,没有错误,但脚本不起作用。

game.Players.PlayerAdded:connect(function(player)
    local folder = Instance.new("Folder",player)
    folder.Name = "leaderstats"
    local currency1 = Instance.new("IntValue",folder)
    currency1.Name = "Cash"

    local increment = 50

    if game:GetService("MarketplaceService"):PlayerOwnsAsset(player,7382818)then 
        increment = increment + 50
    end

    player:WaitForChild("Humanoid").Died:connect(function()
        local tag = player.Humanoid:FindFirstChild("creator")
        if tag ~= nil then
            local killer = tag.Value
            if killer ~= nil then
                -- Find the killer's leaderstats folder
                local killerStats = killer:FindFirstChild("leaderstats")

                if killerStats ~= nil then
                    -- Find the killer's Cash IntValue
                    local killerCash = killerStats:FindFirstChild("Cash")

                    -- Increase cash as before
                    killerCash.Value = killerCash.Value + increment
                end
            end
        end
    end)

我希望拥有游戏通行证的VIP玩家能够获得更多的现金,但是当我对其进行测试时,没有一个玩家会因为杀死另一个玩家而获得任何现金。

1 个答案:

答案 0 :(得分:1)

  

如何在eof附近修复最终预期错误

如果Lua解释器抱怨缺少end,则说明您在某处丢失了它。

通读您的代码,并确保应该用end关闭的所有内容都包含一个。通读Lua参考手册,找出哪些关键字需要end

在您的代码中是if语句和函数定义。从内到外检查每一对,您最终将需要end)短时间才能关闭game.Players.PlayerAdded:connect(function(player),如评论中所述。