Unable to get PlayerScripts

  1. What do you want to achieve? Fire remote in playerscripts or send notification to touched player

  2. What is the issue?
    Touching object triggered game.Players:GetPlayerFromCharacter successfully, but couldn’t get playerscripts.

Log said not member of “Players.(username or unknown)” but able to see it.

  1. What solutions have you tried so far? One way is cloning notification object to player’s gui directly, but it causes capacity flood later.

WaitForChild(“PlayerScripts”) says possible infinity wait.

1 Like

WaitForChild(“playerscripts”)

From what I am aware of last time I checked I think its PlayerScripts.

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

Yeah, this is code.

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)

PlayerScripts isn’t existing to the server, only the client.

1 Like

And I know why failed to fire event.