are you sure the cAps are done correctly?, i see you have tried :WaitForChild(“playerscripts”) but is should be WaitForChild(“PlayerScripts”) with caps on evry new word
local Ready = true
local BadgeId = script.BadgeID.Value
function onTouch(hit)
local h = hit.Parent:FindFirstChild("Humanoid")
if h ~= nil and Ready == true then
Ready = false
local plyr = game.Players:FindFirstChild(h.Parent.Name)
local p = game.Players:GetPlayerFromCharacter(hit.Parent)
local PlayerScripts=p:WaitForChild("PlayerScripts")
local Notifier = PlayerScripts.Notifier.Bookfound
local ds = require(game:GetService("ReplicatedStorage").DatastoreControl)
local dn = script.Parent.Parent.Name
local dsbackup,dsfound = ds.IsbookFound(p,dn)
if not dsbackup and not dsfound then
ds.SavebookFound(p,dn)
local b = game:GetService("BadgeService")
local success, badgeInfo = pcall(b.GetBadgeInfoAsync, b, BadgeId)
local name = badgeInfo.Name
local icon = badgeInfo.IconImageId
local got=b:UserHasBadgeAsync(p.UserId,BadgeId)
if not got and success and badgeInfo.IsEnabled then
print("Awarding BadgeID: " ..BadgeId .. " to UserID: " .. p.userId)
b:AwardBadge(p.userId, BadgeId)
else
Notifier:FireClient(p,name,icon)
end
else
print("Error: Something went wrong!")
end
wait(8)
Ready = true
end
end
-- ROBLOX scripter hackers, see what you can do with this:
-- game:GetService("BadgeService"):UserHasBadge(userid, badgeid)
script.Parent.Touched:connect(onTouch)