Instance.new not working properly

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

  1. I want to create 4 different IntValues to store some data in the player.

  2. The issue is that instead of creating 4 values, it only creates one.

  3. I tried to use the clone function, but it doesn’t work either.

local Folder = Instance.new("Folder")
	Folder.Name = "GiftData"
	Folder.Parent = plr
	
	local TotalGiftedInputs = Instance.new("IntValue")
	TotalGiftedInputs.Name = "Total Inputs Sent"
	TotalGiftedInputs.Parent = Folder
	
	local TotalRecievedInputs = Instance.new("IntValue")
	TotalGiftedInputs.Name = "Total Inputs Recieved"
	TotalGiftedInputs.Parent = Folder
	
	local TotalGiftsSent = Instance.new("IntValue")
	TotalGiftedInputs.Name = "Total Gifts Sent"
	TotalGiftedInputs.Parent = Folder
	
	local TotalGiftsRecieved = Instance.new("IntValue")
	TotalGiftedInputs.Name = "Total Gifts Recieved"
	TotalGiftedInputs.Parent = Folder

Only TotalGiftsRecieved gets created.

Maybe try this? For me, it works fine.

game.Players.PlayerAdded:Connect(function(plr)
	local Folder = Instance.new("Folder",plr)
	Folder.Name = "GiftData"

	local TotalGiftedInputs = Instance.new("IntValue",Folder)
	TotalGiftedInputs.Name = "Total Inputs Sent"

	local TotalRecievedInputs = Instance.new("IntValue",Folder)
	TotalRecievedInputs.Name = "Total Inputs Recieved"

	local TotalGiftsSent = Instance.new("IntValue",Folder)
	TotalGiftsSent.Name = "Total Gifts Sent"

	local TotalGiftsRecieved = Instance.new("IntValue",Folder)
	TotalGiftsRecieved.Name = "Total Gifts Recieved"
end)

The problem isn’t with Instance.new. You’re only setting TotalGiftedInputs's properties.

How come? I’m creating different variables, as well as telling the game to create different instances. Sorry if I’m being a bit annoying, I just want to learn from my mistake.

Underneath each newly created Instance, you’re only doing:

TotalGiftedInputs.Name = NAME
TotalGiftedInputs.Parent = Folder

You’re not changing the new Instance’s properties, just the first one


local TotalGiftedInputs = Instance.new("IntValue")
TotalGiftedInputs.Name = "Total Inputs Sent"
TotalGiftedInputs.Parent = Folder

This work, but

local TotalRecievedInputs = Instance.new("IntValue")
TotalGiftedInputs.Name = "Total Inputs Recieved"
TotalGiftedInputs.Parent = Folder

You’re not changing TotalRecievedInputs

bro youre not parenting nor renaming the other values