Need help detecting when clone changes parent and detecting badges

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I have a system that clones a folder of values to each player when they join then I want each value to detect if a player has a certain badge and set the value into true if they do
  2. What is the issue? Include screenshots / videos if possible!
    It is not detecting the AncestoryChanged basically making nothing happen
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’m pretty stumped on this one i tried some other methods but nothing is responding
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
--Script inside each value getting cloned 
local badge = funny numbers
local BadgeService = game:GetService("BadgeService")
local Value = script.Parent

Value.Parent.Parent.AncestryChanged:Connect(function(parent)
	print("parent changed")
	local player = parent
	if BadgeService:UserHasBadgeAsync(player.UserID,badge) then
		Value.Value = true
	end
end)

--script that clones the values into the player
local OSV = script.OwnerShipValues
game.Players.PlayerAdded:Connect(function(player)
	local OSVcp = OSV:Clone()
	OSVcp.Parent = player
	OSVcp.Name = (player.Name .. "Ownerships")
end)

hope this is a decent amount of explanation lol

Cant you just do?

local OSV = script.OwnerShipValues
game.Players.PlayerAdded:Connect(function(player)
	local OSVcp = OSV:Clone()
	OSVcp.Parent = player
	OSVcp.Name = (player.Name .. "Ownerships")
	if BadgeService:UserHasBadgeAsync(player.UserID,badge) then
		--Whatever value has to bet to be true
	end
end)

well i could but there’s multiple values

Instead of running several different scripts for sever different badges, you can just do 1 script which checks for all and then gives it to the player.

im trying it and its not really working because it says argument 2 is missing or nil
I have a list of all the badges with their names above this which is was badge ID is v.name

ame.Players.PlayerAdded:Connect(function(player)
	local OSVcp = OSV:Clone()
	OSVcp.Parent = player
	OSVcp.Name = (player.Name .. "Ownerships")
	wait()
	for i, v in pairs(OSVcp:GetChildren()) do
		if badgeservice:UserHasBadgeAsync(player.UserId,tonumber(v.Name)) then
			v.Value = true
			print("user has a plush")
		elseif not badgeservice:UserHasBadgeAsync(player.UserId, tonumber(v.Name)) or v.Name == nil then
			v.Value = false
			print("user doesnt have a plush")
		end
	end
end)

Since when you have a bool value, its automatically going to be set to false so you dont need a function to set it to false. So you can just have a bunch of arguments checking whether if a player has a badge, and if that is a yes you can set the value to true.

local OSV = script.OwnerShipValues
game.Players.PlayerAdded:Connect(function(player)
	local OSVcp = OSV:Clone()
	OSVcp.Name = (player.Name .. "Ownerships")
	if BadgeService:UserHasBadgeAsync(player.UserID,BadgeOne) then
		--Set Badge One to true
	end
    if BadgeService:UserHasBadgeAsync(player.UserID,BadgeTwo) then
		--Set Badge Two to true
	end
-- You can have as many checks for badges, if you have 10 use 10 arguments.
    OSVcp.Parent = player
end)

I guess I could do that it’s just that I have >50 badges and was wondering if there was a more efficient way of doing it

You can make a table and go through it.

local BadgeTable = {All your badge ids}

for i, v in pairs(BadgeTable) do
local badgeid = v
	if BadgeService:UserHasBadgeAsync(player.UserID,badgeid) then
          -- Set the value to true
    end
end