Create a local variable for the :Clone part(), parent it, then access it via the variable.
I’m using this to swap, the event is just so I can fire it from the client too.
game.ReplicatedStorage.Events.SwitchCharacters.OnServerEvent:Connect(function(player)
local character = player.Character
if character.Name == "Player1" then
local clone1 = game.Workspace.Player1:Clone()
clone1.Parent = game.Workspace
player.Character = game.Workspace.Player2
elseif character.Name == "Player2" then
local clone2 = game.Workspace.Player2:Clone()
clone2.Parent = game.Workspace
player.Character = game.Workspace.Player1
elseif character.Name ~= "Player1" and character.Name ~= "Player2" then
player.Character = game.Workspace.Player1
end
end)
I could combine my current script and the one that swaps them I guess, and that would then give me the variable, or I could use an object value, which would probably be easier.
I don’t really understanding why you are cloning one character, then trying to parent it the other one.
Also, change the current character name to the player name, so it won’t be picked up by the script again.
Otherwise, every time, players will switch the same character between each other
its what had to be done, because if not it would glitch back to the original character it swaps you to. also this is a single player game
Clone the same character, and just rename it so it won’t be picked up again.
it gets destroyed, and the players won’t swap between the same ones as its gonna be a single player game. also I knew it would be an issue with multiple people as my play tests are sometimes crashed by my brother messing up the movement
Ah, that explains it.
When you switch characters, do you want the character to replace the current in the same location? Or a different one?
Sometimes, the character just falls of/disappears if isn’t positioned well.
It doesn’t teleport to the original character on default.
it swaps just fine, the issue is I can’t reference the character without it coming out nil
Previous post, not the most effective solution, but it works. Not sure if this is what you were asking for.
see I’m not morphing the character, I’m actually changing it to an entirely deferent rig, and I have it working, but the issue is that I can’t reference the character without it being nil.
Is the property Archivable of the character set to true?
Archivable off disables :Clone()
That’s exactly what I posted, using startercharacter you can change it to literally anything.
I saw that, and I did research and its not a good way to do it as its not an official thing.
Archivable is on, I can clone it just fine for the swapping, I just can’t reference the charcter outside of that script for some reason
Understandable, but going about it in a different way may be too hacky. This was a pretty simple solution to this, at least for me.
I think I’ll just put the current Character in an object value and use it instead of going on trying to find out a better way.
I am not sure.
Yet, I don’t get why you clone a character then set it to the other one.
If you don’t destroy them, wouldn’t it create unnessecary clones?
Try doing like this:
game.ReplicatedStorage.Events.SwitchCharacters.OnServerEvent:Connect(function(player)
local character = player.Character
if character.Name == "Player1" then
player.Character = game.Workspace.Player2
elseif character.Name == "Player2" then
player.Character = game.Workspace.Player1
else
player.Character = game.Workspace.Player1
character:Destroy() --Destroy the old character that is now switched.
end
end)
The 2 characters already exist in the workspace, don’t they? Just switch between them.
Also, change the CameraSubject to your new humanoid from a local script.
I’m presuming you’re wanting to achieve a character from another player model, therefore, you could seek a usage with hum:GetAppliedDescription(), which returns back a copy of the target’s avatar, and it can be used with hum:ApplyDescription() to load in for the player. Take a look at the links for in-depth details.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.