Player Folder is Invisible to Server

I am manually parenting a folder to the player, and expecting the server to be able to see it

Here is my script that changes the parent:

wait()
script.Parent.Parent = game:GetService("Players").LocalPlayer;

Here is where the folder lands on the client’s side:

image

And this is what happens on the server’s side:

image

It’s nowhere. How can the server see the player’s backpack but not my poor folder?

Why is this happening and what would be a way for the server to see my folder?

2 Likes

Is the script in local? if so that is the problem

The LocalPlayer property of the player’s service is not defined in server scripts (it’s nil).

You’re running the code from a local script, so the server won’t see the change. Try this in a server script:

game.Players.PlayerAdded:Connect(function(plr)
    script.Parent.Parent = plr --// change `script.Parent` to reference what you're trying to move.
end)
1 Like

His script is in local of the context I assume.

If you’re creating a “Folder” instance from the client then it won’t replicate to the server, instead you need to instance the folder from the server, so that it replicates to the server and to the client.

local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
	local _stats = Instance.new("Folder")
	_stats.Name = "Stats"
	_stats.Parent = player
end)

Put this in a server script inside the ServerScriptService folder.

Now it doesn’t change locally.

Uh, you know that since you’re doing it on a localscript, it won’t replicate to the server right? You should do a thing like Players.PlayerAdded:Connect() then cloning and parenting the stats to the player.

I am aware of that now. I now have a server script that says:

game.Players.PlayerAdded:Connect(function(player)
	wait();
	script.Parent.Parent = player;
end)

Here is where it is located:
image

I want both server scripts and LocalScripts to access it. But how?

I’ve got it to work now. I basically had to use @ZoomSummit’s code and move my script in ServerScriptService.