Object Value not being added after Player is Added

Can someone tell me why it’s not adding the Object Value into a folder inside of the ServerStorage property?

The Folder in ServerStorage (looked from the Server Side not Client Side):
serverside

I have this code inside a Server Script that is also inside of the ServerScriptService property.

Here’s the code:

repeat task.wait() until game:IsLoaded()
task.wait()

local ServerStorage = game:GetService("ServerStorage")


game.Players.PlayerAdded:connect(function(player)
	local checkpointData = ServerStorage:WaitForChild("CheckpointData")
	
	local userIdString = tostring(player.UserId)
	
	local checkpointValue = Instance.new("ObjectValue")
	checkpointValue.Name = userIdString
	checkpointValue.Parent = checkpointData
end)

I’m trying to get the player’s userid and be the ObjectValue inside of the folder.

repeat task.wait() until game:IsLoaded()
task.wait()

local ServerStorage = game:GetService("ServerStorage")
local checkpointData = ServerStorage:WaitForChild("CheckpointData")

game.Players.PlayerAdded:connect(function(player)
	print(player.Name.." just joined!")
	local checkpointValue = Instance.new("ObjectValue")
	print("Value made")
	checkpointValue.Name = tostring(player.UserId)
	checkpointValue.Parent = checkpointData
	print("Value parented")
end)

Just some cleaning and may I ask if it prints any error or not?
If it doesn’t use the prints I included above.

I tried doing this, but it didn’t print anything.

Where did it not print anything? The first statement? Second? Third?

There were no errors, the output didn’t say anything.

Then its probably due to your repeat loop at top.

1 Like

Also for some weird reason from the client side the Folder is not there, but on the server side it is.

Oh ok I’ll try without the repeat loop

Oh alright, I removed the repeat loop and now the whole code works now. Thank you so much!

Wow. Didn’t expect that. No problem. Glad I could help you.

1 Like

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