I’ve been looking for just a simple answer but I can’t find anything clear. All I’m trying to do is reparent the player’s character model to a folder in the workspace via the server. How would I go about this or am I just blind and didn’t see an article? If so, please link it.
maybe because your character doesn’t spawn in when you do the checks.
so we can do a forever loop that checks if ur character is in workspace and not
in folder, sorry for bad explanation
while wait() do
for i,v in pairs(game.Players:GetChildren()) do
if workspace:FindFirstChild(v.Name) then
v.Character.Parent = workspace.Interactive
end
end
end
This makes it so that everytime it detects a character in the workspace it will automaticly put it in the folder.
edit I created a folder name "Interactive" and used the script that I've created, and it works!
Success! Thank you for the help. Just a question though, why isn’t the character loaded when CharacterAdded is triggered? I get that appearance might not load right away but shouldn’t the model itself where objects can load into be parented?
That doesn’t seem to be working. I’m not an expert with these things though, sorry.
There is also another event feature of player class called player:CharacterAppearanceLoaded()
that waits for the appearance to load
maybe one day it will help u
If there are other things interacting with the script, what might happen in solo testing is that the player gets added before the PlayerAdded event get set up, though that is probably not the issue, what might be the issue is the Character get added too quickly and any changes you make are applied too quickly, so, here are a few fixes, the first one, is to loop through the GetPlayers() method once after setting up PlayerAdded so players already in the game will also have the function ran, and the second fix will be to simply wait 1 second before applying changes, also, check if the character has spawned in already, so it also gets the change
local function onCharacterAdded(char)
wait(1)
char.Parent = workspace.Interactive
end)
local function onPlayerAdded(plr)
plr.CharacterAdded:Connect(onCharacterAdded)
local char = plr.Character
if char then
onCharacterAdded(char)
end
end)
game.Players.PlayerAdded:Connect(onPlayerAdded)
for i, v in ipairs(game.Players:GetPlayers()) do
onPlayerAdded(v)
end
in this post, TheGamer has a list that shows the order of how character loading works. keep in mind the proposed “new” loading is not live yet so currently roblox uses the “old” method. you can see that a bit after CharacterAdded is fired, the game will parent the character to the workspace. that means if you try to immediately parent the character after CharacterAdded, the game will just reparent them to the workspace