【问题标题】:Why does my Roblox joining badge not work?为什么我的 Roblox 加入徽章不起作用?
【发布时间】:2023-03-12 09:00:02
【问题描述】:

我制作了一个访问或感谢加入徽章,我为任何加入我的游戏的新人制作了徽章,但它仅在某些时候有效。

我什么都尝试不了,徽章在 146 人加入时给了 60 人!所有 146 人都应该得到它!

这是徽章代码:

local badgeID = 2124446943
local badgeService = game:GetService("BadgeService")
function onEntered(player)
wait(1)
if not badgeService:UserHasBadge(player.UserId, badgeID) then
    badgeService:AwardBadge(player.UserId, badgeID)
end
end

game.Players.PlayerAdded:Connect(onEntered)

它应该给所有访问过的人。因为在某些时候它们都是新的!

【问题讨论】:

  • 是否有任何游戏日志可以查看何时触发?也许那里有关于为什么这个 id 不触发 86 人的线索?

标签: roblox


【解决方案1】:

不太可能只有 60 个独特的人玩过您的游戏,但他们所有人都至少玩过您的游戏两次,从而获得了 146 次访问

另一种可能是一些玩家在你的函数中等待(1)之前断开连接,所以不妨试试这个:

function onEntered(player)
    repeat wait(0.1) until player ~= nil
        if not badgeService:UserHasBadge(player.UserId, badgeID) then
            badgeService:AwardBadge(player.UserId, badgeID)
        end
    end
end

但我不认为这会产生任何影响,因为如果玩家进入,他们就不能为零......(idk这是一个随机建议不要指望我)

对不起,我想发表评论而不是在这里输入,但我需要 50 声望才能这样做

【讨论】:

  • 重复循环是不必要的,因为在 PlayerAdded 中播放器永远不会为零。即使 player 以某种方式为零,也会导致无限循环,因为 player 从未设置。
猜你喜欢
  • 1970-01-01
  • 2021-11-24
  • 2023-02-18
  • 2018-02-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-04-25
  • 2021-08-29
相关资源
最近更新 更多