Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to change character appearance without having them respawn? *EDIT*

Asked by 6 years ago
Edited 6 years ago

EDIT Ok I think I may have figured it out but I'm still testing it. my new code is this:

1player.CharacterAppearanceId = player.UserId
2player:LoadCharacter()

the character must be loaded afterwards but I'm still testing to see if it will fully work. so far, so good

So basically in the game I'm making, a player's model is changed depending on which type of character they have equipped. I want to morph them into the character they chose but when looking online for an R15 morph script I was unable to find one that worked. When they are teleported into the playing area I was able to override their appearance with this code:

This code removes all accessories and then changes the appearance and skin color with a function I made. It isn't the problem, but this is something I want to avoid because if this is the only way then I'll have to save each players' accessories and load them which will be very annoying

01---remove all accessories
02local pants = player.Character:FindFirstChild("Pants")
03if pants then
04    pants:remove()
05end
06local shirt = player.Character:FindFirstChild("Shirt")
07if shirt then
08    shirt:remove()
09end
10local tshirt = player.Character:FindFirstChild("Shirt Graphic")
11if tshirt then
12    tshirt:remove()
13end
14 
15local everythingElse = player.Character:GetChildren()
View all 22 lines...

This works however, when they are teleported back into the lobby, I can't quite get their appearance to change back to what it normally was with this code:

1--reset appearance
2for i, player in ipairs(game.Players:GetChildren()) do
3    player.CharacterAppearanceId = player.UserId
4    print("reset")
5end

Basically I'm just asking if there is a way to reset the user's character to their original model without having to reset them. Kind of like a way to morph them into a certain character that you have saved. If anyone has an idea please let me know, thanks.

0
I am working on getting solution. PlaasBoer 275 — 6y
0
I know practically nothing but just a random hunch: there is a small chance that somehow changing the character value in player to a different character could possibly change you to that character. As I said, I have really no idea. OBenjOne 190 — 6y
0
@TheeDeathCaster I think it only works for models because it says it is not a member of player sonicfan0405 18 — 6y
View all comments (3 more)
0
Try to figure it out yourself and if you really struggle too long then use my code. PlaasBoer 275 — 6y
0
Combine that with TheeDeathCaster link PlaasBoer 275 — 6y

2 answers

Log in to vote
0
Answered by
PlaasBoer 275 Moderation Voter
6 years ago
Edited 6 years ago

Okay so I tried using Roblox api but I saw TheeDeathCaster comment and now I have two ways to do it I will post the both

Both is test.Only for the first one with local test players like Player1 etc not work.

Note. Instead of using that code to remove stuff use the player api. player:ClearCharacterAppearance()

Read more https://wiki.roblox.com/index.php?title=API:Class/Player/ClearCharacterAppearance

First option

Thanks to TheeDeathCaster for GetCharacterAppearanceAsync

01--Use this instead of that custom function make sure to get the player instance.
02--E.g local player = game.Players.PlaasBoer  That will get my player.
03 
04player:ClearCharacterAppearance()
05 
06--This function reset appearance when called.
07--This function will add the player appearance just pass the player through the argument when using it.
08function loadCharacterAppearance(player)
09    if player.UserId then
10        local theModel = game.Players:GetCharacterAppearanceAsync(player.UserId)
11        for _, child in pairs(theModel:GetChildren()) do
12            player:LoadCharacterAppearance(child)
13        end
14    end
15end

Second option

Instructions Add folder name Characters to game.ServerStorage

01--This will add the character model to folder name Characters in ServerStorage
02game.Players.PlayerAdded:Connect(function(player)
03    player.CharacterAdded:Connect(function(character)
04        if game.ServerStorage.Characters:FindFirstChild(player.Name) == nil then
05            character.Archivable = true
06            wait(2)
07            character:Clone().Parent = game.ServerStorage.Characters
08        end
09    end)
10end)
11 
12--When player leaves game this will remove the character model so that game don't use too much space
13game.Players.PlayerRemoving:Connect(function(player)
14    local playerCharacter = game.ServerStorage.Characters:FindFirstChild(player.Name)
15 
View all 29 lines...
Ad
Log in to vote
0
Answered by
royee354 129
6 years ago

You can use an outside script to reset this script or just put it in starter pack if it is local so when he die or reset the character will have this script running again Disabled is the property of a Script disable a script and then undisable it and it will run again.

Answer this question