Hello, question is in title. So every frame in gui has own NumberValue called AddPoint and value = 1 or 2 or 3 etc. Here is ss: https://gyazo.com/b137211706491b9bec8f38b0e270162f When player summon pet, it should take AddPoint value from summoned pet frame and place it in created NumberValue in player's pet. Here is problem, because it takes value only once from first summoned pet. I tried to summon second pet and check if it'll import his value, but nope still takes value from first one..

Here is script:

sp = script.Parent

local player = game.Players.LocalPlayer
local PlayerStats = game.ReplicatedStorage.PlayerStorage:FindFirstChild(player.Name)
local plrGui = player:FindFirstChild("PlayerGui")
local pets = plrGui.PetGui.Pets:GetChildren()

function waitfor(a,b)
	while a:FindFirstChild(b) == nil do
		a.ChildAdded:wait()
	end
	return a:FindFirstChild(b)
end

local add = waitfor(sp, "Add")

for i, v in pairs(pets) do
	if v.ClassName == "Frame" then
		if PlayerStats ~= nil then
			while wait(2) do
				add.Value = v.AddPoint.Value
				PlayerStats.Value = PlayerStats.Value + add.Value
			end
		end
	end
end

"local add" is already created by different script.

2 comments

0

You can use :WaitForChild() instead of your waitfor function.

0

True, but it won't fix this problem.