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
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!)
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.
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.
Ok so I did some research and turns out that :ChangeCharacterAppearance() has been deprecated. The new methods are found here: Humanoid - Apply Description
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()
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()