Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I change the player's appearance with a script?

I have a button that is supposed to allow the player to change their appearance to another appearance that is stored in ReplicatedStorage, but when I click the button the players I can see the script relocating the StarterCharacters correctly but even after I reset my player the player's appearance still doesn't change. Any Help? (Explanations Please)

local player = game.Players.LocalPlayer
local StarterPlayer = game.StarterPlayer
local Luisaine = game.ReplicatedStorage:FindFirstChild("Luisaine"):FindFirstChild("StarterCharacter")
local Button = script.Parent
local deb = false

Button.MouseButton1Click:Connect(function()
	local PreviousCharacter = game.StarterPlayer:FindFirstChild("StarterCharacter")
	if deb == true then return end
	deb = true
	PreviousCharacter:Destroy()
	wait(0.1)
	local LuisaineAvater = Luisaine:Clone()
	LuisaineAvater.Parent = StarterPlayer
	LuisaineAvater.Name = "StarterCharacter"
	wait(0.1)
	player:LoadCharacter()
	wait(0.1)
	deb = false
end)

3 comments

0

set the player's CanLoadCharacterAppearance property to false

0

So I would do that by adding "player.CanLoadCharacterAppearance = false" to my script or like "StarterPlayer.LoadCharacterAppearance = false"?

0

player.CanLoadCharacterAppearance

1 answer

✓ Accepted answer

According to the Output, Player:LoadCharacter can only be performed on the server. With this in mind, you will need a Remote Event

Server Script under ServerScriptService

local Remote = Instance.new("RemoteEvent")
Remote.Name = "CharacterChoice"
Remote.Parent = game:GetService("ReplicatedStorage")

local StarterPlayer = game:GetService("StarterPlayer")
local Luisaine = game:GetService("ReplicatedStorage"):WaitForChild("Luisaine"):WaitForChild("StarterCharacter")

Remote.OnServerEvent:Connect(function(Player)
	game:GetService("StarterPlayer"):WaitForChild("StarterCharacter"):Destroy()
	wait(0.1)
	local LuisaineAvater = Luisaine:Clone()
	LuisaineAvater.Parent = StarterPlayer
	LuisaineAvater.Name = "StarterCharacter"
	wait(0.2)
	Player:LoadCharacter()
end)

Local Script under Text / Image Button

local player = game.Players.LocalPlayer
local StarterPlayer = game:GetService("StarterPlayer")
local Button = script.Parent
local deb = false

local Remote = game:GetService("ReplicatedStorage"):WaitForChild("CharacterChoice")

Button.Activated:Connect(function()
	local PreviousCharacter = StarterPlayer:FindFirstChild("StarterCharacter")
	if PreviousCharacter then
		if deb == true then return end
		deb = true
		Remote:FireServer()
		wait(0.3)
		deb = false
	end
end)

The above scripts combined do the exact same thing as you had before, except splits them between the server and the client.

I also changed MouseButton1Click to Activated since Activated works for all devices, not just computers.

The server script creates a RemoteEvent for you, so you don't have to do that manually

1 comment

1

Thank you VERY much!

This discussion is preserved as it was. New answers, comments, and votes are closed.