How would I make it so that a script creates a folder before another script calls on the folder?

Hello fellow scripters! I have been working on a pet system for a few days, and i have almost finished it. The only problem is, i need a script to create a folder before another script calls on the folder. I have tried many things to make this work, but nothing has. Any help would be appreciated!

Part of the Script calling on the folder:

Players.PlayerAdded:Connect(function(player)
	local ActionValues = player.ActionValues
	
	local PPs = Instance.new("Folder")
	PPs.Parent = ActionValues
	PPs.Name = "PlayerPets"
	
	local folder = Instance.new("Folder")
	folder.Parent = PPs
	folder.Name = player.Name
end)

Part of the Script creating the folder:

game:GetService("Players").PlayerAdded:Connect(function(PlayerWhoAdded)
	local ValuesFolder = Instance.new("Folder")
	ValuesFolder.Name = "ActionValues"
	ValuesFolder.Parent = PlayerWhoAdded

If you need anything else, just let me know.

1 Like

You can add repeat wait() until loop to detect the folder… or just merge the 2 scripts together

1 Like

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