簡體   English   中英

徽章給予者幫助(roblox)

[英]badge giver help (roblox)

所以,我正在開發 Roblox 游戲,我想制作一個密室並獎勵找到它的玩家一枚徽章,但問題是徽章贈送器不起作用,我的徽章贈送器也被鎖定,所以我不能不要不小心把它放在 map 中。它也在密碼門后面,周圍都是上鎖的部件。 這是我的代碼。

local badgeService = game:GetService("BadgeService")
local id = 2133435079

script.Parent.Touched:Connect(function(hit)
    
    if hit.Parent:FindFirstChild("Humanoid") then
        
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        badgeService:AwardBadge(plr.UserId,id)
    end
end)

我嘗試解鎖徽章提供者,但沒有用。

我也嘗試過常規測試,但也沒有用

根據錯誤,聽起來您沒有防止plr為零的情況。 如果hit.Parent不是玩家的角色 model,就會發生這種情況。

local badgeService = game:GetService("BadgeService")
local players = game:GetService("Players")
local id = 2133435079

script.Parent.Touched:Connect(function(hit)
    local plr = players:GetPlayerFromCharacter(hit.Parent)
    if plr then
        badgeService:AwardBadge(plr.UserId, id)
    end
end)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM