Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Moving Player Character on Join not working for every player?

Hello.

I am currently trying to make a game where you can place notes in a certain building where it is allowed. This works perfectly fine, however, I've noticed that there is a bug with the placement system being able to place the note on Players. Since I have a folder that contains the parts that are blacklisted from the note placement (meaning the note will not be able to be placed there) I thought that adding the player's character to that folder when the character is added would fix it. And it does the job correctly, however, it only works for one person.

Meaning that one person won't be able to place notes on another person while the other person will. The script that I wrote for this is quite simple, and I've also done some testing ingame and I've also noticed that all the characters that do join do indeed get parented to that folder, but for some reasons, like explained before, it only works for one person.

I've made sure that the script I use for the note placement system gets the Descendants instead of the Children so it gets everything in the folder.

Here's the script:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		wait()
		Character.Parent = workspace.Players -- Folder
	end)
end)

I'm not sure why this only works for one person in the game, however, my thoughts is that it needs to be cloned, however, when I try to do so It bugs out completely.

If anybody could help me with this, it would be great.

Thanks!

1 answer

Have you noticed this?

local Players = game:GetService("Players") -- Right here
-- ...

		Character.Parent = workspace.Players -- And right here


What you're doing here is telling the compiler to look for the Players service under workspace. This is not only wrong, but it's a rookie-level mistake. You should, for logical purposes, rename the variable that points to the Players service to avoid interception between workspace.Players and the Players variable.

4 comments

0

Players was the Folder name

0

Even with a folder rename, it still has the same issue. I actually had the folder renamed to something else, although for reading purpuses I had renamed it to Players for this post, and hadn't realised about that, good catch on that! Anyways, like said before, even whilst having a folder named IngamePlayers (as for my game) the same issue occurs.

0

Oh my god... And you have 3k reputation too...

0

They have no relation whatsoever, nor is the compiler misunderstanding....

This discussion is preserved as it was. New answers, comments, and votes are closed.