I did the Character Switch System and it worked earlier.
The problem is that the scripts gets broken because of character.
I tried to somehow fix this, no results.
Server switches player’s character to new one, and it did successfully. The new character gets added, old character gets deleted, even Properties says on client/server that character has been changed. But the client scripts don’t understand that, they receive old character instead of new one.
charRespawnE.OnClientEvent:Connect(function()
local humanoid = player.Character:FindFirstChildOfClass("Humanoid") :: Humanoid
camera.CameraSubject = humanoid
print(player.Character) -- prints old player character
ControllerModule.new()
end)
You are firing the remote before a function which you didn’t share, could be some issue in that function, sharing that function could help. Also if the sever has the correct new character try passing that to to the client and using that.
Would it work if you added a small delay? It could just be that the event reaches the client before the property replication does. I can’t figure out anything else that’s wrong with this…
function does additional stuff not related to the issue.
i can share it anyways.
function setupCharacter(character: Model)
local player = Players:GetPlayerFromCharacter(character) :: Player
local humanoid = character:FindFirstChildOfClass("Humanoid") :: Humanoid
humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
Ragdoll.new(character)
humanoid.Died:Once(function()
Ragdoll:MakeRagdollClone(character, true, 25)
end)
player.CharacterRemoving:Once(function()
player:FindFirstChild("PlayerTeam").Value = "Neutral"
end)
end
I don’t think there is a way to do it properly other than the delay. You could maybe wait for a descendant to enter the workspace which has a tag unique to the character model, and then check if it’s equal to the player’s character property (or just use an attribute which is set to the player’s user ID so you don’t have to wait for the property)