My problem is that for some reason the client-side script does not correctly receive the cloned player’s character.
In the first module client-side script I specify:
onSpawnPlayer.OnServerEvent:Connect(function(player,character,play)
if play then
onSpawnPlayer:FireClient(player,character,play)
warn(character.Name)
warn(character)
warn(character.Parent)
end
end)
The result is that instead of a character I get nil.
There are no warnings other than my own in the debug messages.
Here is the part of the client script where I clone the player character and pass it as an argument to the module:
local newCharacter=character:Clone()
newCharacter.Parent=workspace
newCharacter.Name="cloneCharacter"..player.Name
animationSpawnModule.AnimationSpawn(newCharacter)
In the module I get this argument:
function animationSpawnModule.AnimationSpawn(character,color)
onSpawnPlayerClone:FireServer(character,true)
In the 3rd server script I initialize events and send them to the client, and it is in this script that I receive nil instead of character:
onSpawnPlayer.OnServerEvent:Connect(function(player,character,play)
if play then
onSpawnPlayer:FireClient(player,character,play)
warn(character.Name)
warn(character)
warn(character.Parent)
end
end)
Here is the part of the client script where I should get the character but I get nil:
onSpawnPlayer.OnClientEvent:Connect(function(cloneCharacter,play)
if play then
cutSceneStart(cloneCharacter)
print("cloneCharacter is a valid object: "..cloneCharacter.Name)
end
end)
Client? Are you passing the localplayer? I’ve never tried passing a localplayer value to the server before but it’s possible that the server cannot get localplayer character therefore resulting in nil
It also seems like the character clone is being created on the client too, so the server can’t access it because it’s not created on the server
Either try doing everything on the same script (which will make your thing client-sided) or fire a remote event to the server for the creation of the character clone.