Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to properly assign a player's character to a folder in the workspace?

Asked by 4 years ago
Edited 4 years ago

I need a system to automatically put a player's physical character into a folder called "Spectating" once they join. I've tried this but it doesn't seem to be working. I have a feeling I may be using the wrong format.

function onCharacterAdded(character)
    character.Parent = workspace.Spectating
end

There's nothing showing up in Output about character being a nil value so I really don't know.

1 answer

Log in to vote
0
Answered by
Aztralzz 169
4 years ago
Edited 4 years ago

Try to make a script in SSS, with this line of code.

game.Players.PlayerAdded:Connect(function(player)
wait(2)
player.Character.Parent = workspace.Spectating
end)

You have to actually connect the function to something, which in that case is detecting if a Player joined, and when that happens, the function fires. Hope I helped!

0
I got an "attempt to index nil value with Parent" error. How should I fix this? OrchestralGuy 11 — 4y
0
Try this, I changed the answer. Aztralzz 169 — 4y
0
Ok, this will work, all you have to do is add a delay. :D Aztralzz 169 — 4y
0
The delay worked! OrchestralGuy 11 — 4y
Ad

Answer this question