How to change multiple values based on values from another folder?

  1. What do you want to achieve? Keep it simple and clear!
    I want individual intvalues in one player stat folder to change based on a different player stat folder with stringvalues.

  2. What is the issue? Include screenshots / videos if possible!
    All intvalues found in folder are changing value automatically to 1 even though some should be 0 based on the stringvalue with same name from other folder that have “none” or blank value.
    The way it should work is if string value equals intvalue.name then intvalue should become 1, otherwise stay at 0.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Alot of trial & error, research on how to use ipairs and couldnt find this topic.

code is placed in a folder in startergui by the way.
here is code:

local Player = script.Parent.Parent.Parent
repeat wait() until Player.Character
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")

local PlayerStats = Player:WaitForChild("PlayerStats")
local inventoryFolder = Player:WaitForChild("Inventory")

for i, v in pairs(PlayerStats:GetChildren()) do
	if v ~= "None" or " " then
		inventoryFolder:FindFirstChild(v.Name).Value = 1
		else
		inventoryFolder:FindFirstChild(v.Name).Value = 0
	end
end	
		
wait(1)
script:Destroy()

Any help is greatly appreciated, Thanks in advance!

Try changing this to v.Value rather than v.

You can rewrite it to use the values of the v stringvalue instance

for _, obj in PlayerStats:GetChildren() do
    if obj.Value == "None" or obj.Value == "" then continue end --skip if value is none
	local inventoryObj = inventoryFolder:FindFirstChild(obj.Name)
        
    if inventoryObj then
       inventoryObj.Value = 1
    end
end	
1 Like

Tried it, didn’t work though. Ive tried many variations. Closest I get is it changes to 1

This worked, thanks alot,really appreciate it.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.