I have an extremely simple code here in StarterCharacterScripts that moves the character model to a different folder in the workspace, and when it dies, it moves back into the workspace.
However, I began to notice that the ForceField object that surrounds the player after spawning doesn’t seem to work like usual. Instead, it appears at coordinates 0,0,0 instead of following the player. It disappears after a while though, like normal. Is there be a fix to this? And, if possible, is there a better way to choose what folder that the character spawns in? Thanks!
That’s a really odd behavior. Instead of relying on StarterCharacterScripts, move the script to ServerScriptService and utilize Players service. From here, you want to use PlayerAdded followed by CharacterAdded.
Caution is that there is instances where the character seems to already exist upon start-up, meaning that Player.Character already exists and Player.CharacterAdded doesn’t fire.
Once CharacterAdded is fired, parent the character to the folder. Or I should actually advise you to use a custom character loading logic instead, disabling the default spawning method.
Hey! I wonder why I haven’t thought of that. I’ll try this when I get the chance.
edit: @Operatik, that didn’t seem to work. Which is strange to me, as nothing is changing about the ForceField. It’s always parented to the character. None of my scripts in my entire game even involve a ForceField.
I noticed it’s not working for me either, what are you trying to have the Player folder for?
I could say if it’s to hold a players stats or scripts or something, you could maybe use PlayerAdded in which it creates a stat/folder parented under Player folder named after whoever has joined the server, and deletes it when they are Removed.
My example:
local Players = game:GetService("Players") Players.PlayerAdded:Connect(function(player)
local a = Instance.new("StringValue")
a.Parent = game.Workspace.Players
a.Name = player.Name
end)
Players.PlayerRemoving:Connect(function(player)string.find(player.Name, player.Name) --prob useless so just workspace.Players.player:Remove() or something
end)