(URGENT!) Why is this happening?

so here is my script:

wait(3)
local chosen = math.random(1, #game.Players:GetChildren())
local lavamonke = game.Players:GetChildren()[chosen]
print(lavamonke)
local monkeyclone = game.ServerStorage.LavaMonke:Clone()
monkeyclone:GetChildren().Position = lavamonke.Character.HumanoidRootPart.Position
monkeyclone.Parent = workspace
lavamonke.Character = monkeyclone

I’m trying to make it choose someone to be it and change their avatar to a different avatar, but i need the new avatar to be at the same position as the current one so i tryed but it didnt work. no errors, just doesnt work :frowning:

1 Like

Its CharacterInstanceHere.PrimaryPart.CFrame = clonedCharacter.PrimaryPart.CFrame. thats my guess.

GetChildren returns an array so you’d have to use a in pairs loop and then go thru it and manually set the positions. BUT! That would be weird because all the body parts would go to the same place and look all janky.

So, the model should have a HumanoidRootPart so you can set the CFrame of it to the previous character’s HumanoidRootPart’s CFrame

(make sure to delete the old character model after setting it unless you don’t want to!)

1 Like

this should work:

wait(3)
local chosen = math.random(1, #game.Players:GetChildren())
local lavamonke = game.Players:GetChildren()[chosen]
print(lavamonke)

local monkeyclone = game.ServerStorage.LavaMonke:Clone()
monkeyclone.HumanoidRootPart:PivotTo(lavamonke.Character.HumanoidRootPart.Position)
monkeyclone.Parent = workspace
lavamonke.Character = monkeyclone

2 Likes

The only problem with this line is that you’re ONLY setting the position of the HumanoidRootPart. However if you use its CFrame, it’ll pivot the whole character model.

You could also write:

monkeyclone:PivotTo(lavamonke.Character.HumanoidRootPart.CFrame)
2 Likes

works, but now the camera doesnt follow the player for some reason

You could probably change the CameraSubject to the monkeyclone’s humanoid using a local script.

Sounds like you are wanting to change the player’s appearance and reload them. Why not check out

1 Like

Doesn’t seem to be much help, could you give like a example of what it would be used for?

I’ll take a shot at it …

local player = game.Players.LocalPlayer
local newAvatarAssetId = "INSERT_ASSET_ID_HERE"

local function changeAvatar()
    local character = player.Character
    if character then
        character:Destroy()
    end

    local success, model = pcall(function()
        return game.Players:LoadCharacterModel(newAvatarAssetId)
    end)

    if success then
        model.Parent = game.Workspace
    else
        warn("Failed to load new avatar")
    end
end

game:GetService("UserInputService").InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton1 then
        changeAvatar()
    end
end)

This shouldn’t need to be repositioned in anyway. It should totally replace the player avatar.
Not tested and yes I’m guessing a bit … Not sure how you’re triggering this. You may need to replace the mouse part with your random pick. This is a different approach than cloning anything. Tring to directly change the players avatar with this.

Did you read through it? Sounds exactly like what you are trying to accomplish.

Ok so I did some research and turns out that :ChangeCharacterAppearance() has been deprecated. The new methods are found here: Humanoid - Apply Description

I created a sample place for you to try. Hope it helps.
HumanoidAppearance Example for xxoof_oofoofxxALT.rbxl (138.7 KB)

Have you used Player.CharacterAppearenceId ?

I’m changing the player’s character to a model, this is my script so for, what would i change it so it works with a model?







wait(3)
local chosen = math.random(1, #game.Players:GetChildren())
local lavamonke = game.Players:GetChildren()[chosen]
print(lavamonke)


local player = lavamonke
local newAvatarAssetId = game.ServerStorage

local function changeAvatar()
	local character = player.Character
	if character then
		character:Destroy()
	end

	local success, model = pcall(function()
		return game.Players:LoadCharacterModel(newAvatarAssetId)
	end)

	if success then
		model.Parent = game.Workspace
	else
		warn("Failed to load new avatar")
	end
end


		changeAvatar()

So you want more guesses? :slight_smile:

task.wait(3)
local chosen = math.random(1, #game.Players:GetChildren())
local lavamonke = game.Players:GetChildren()[chosen]
print(lavamonke)

local player = lavamonke
local newModel = game.ServerStorage:WaitForChild("YourModelName") 
local function changeAvatar()
	local character = player.Character
	if character then
		character:Destroy()
	end

	local success, model = pcall(function()
		return newModel:Clone()
	end)

	if success then
		model.Parent = game.Workspace
	else
		warn("Failed to load new avatar")
	end
end
changeAvatar()