How can i make it so when the player presses a gui button it changes to one if these characters

I want the player to press a button and change to whatever character that button represents. for example: The button is red. witch changes the players character to the red player.
character example

Is this possible? just wondering

4 Likes
local character = game.Players.LocalPlayer.Character
local location = character.CFrame
model = (colored character):Clone
game.Players.LocalPlayer.Character = model
model.CFrame = location
model.Parent = game.Workspace
character:Destroy

taken from here: How to change custom character during game - #6 by goldenstein64

1 Like

Just forgot to say some things.

I want the ability to save the players apearence incase the player dies, leaves, or teleports to a level in my game.

2 Likes

Im not sure of this but I think that the player regains their character when they die. pls correct me if Im wrong
if not I can make a script

Roblox searches for the players avatar (or the startercharater) and copys it and then loads it as the players character im pretty sure.

I thought that it resets the character because a game I played only resets the character by killing the player. but its fine give me a little bit Im gonna right a script

local character = game.Players.LocalPlayer.Character
local location = character:GetPrimaryPartCFrame()
local plrcheck = 0
model = (colored character):Clone
game.Players.LocalPlayer.Character = model
model:SetPrimaryPartCFrame(location)
model.Parent = game.Workspace
for i, v in pairs(game.ReplicatedStorage:GetChildren()) do
	if v == character then
		plrcheck = 1
	end
end
if plrcheck == 0 then
	character.Parent = game.ReplicatedStorage
end
1 Like

Models dont have cframe it just gives you a error. Models only have orgin and Worldpivot no cframe

in the for loop it check for every thing that is currently in the replicated storage. and if there is, it sets a variable to one. that variable is used in an if statement to check if the variable is equal to 0 to put the character in the replicated storage so that there arent multiple characters in the replicated storage. baically it checks if the character was already stored to not store many. tell me if u want to explain the stuff above the for loop

I edited it. it should work now

it works but when i reset the player just never respawns. All the gui on the screen turns into dust.

give me a sec I will fix it might take some time

Ill create a new post just asking how i can change the players bodycolor and then save it

looks like Im late haha. Im finished with the script it works as intended. not sure if u want it anymore. Im gonna post it anyways for people that find this post in the future

local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local debounce = false

script.Parent.MouseButton1Click:Connect(function() -- your function whatever it is
	if not debounce then
		debounce = true
		local character = game.Players.LocalPlayer.Character
		local location = character:GetPrimaryPartCFrame()
		local plrcheck = 0
		local model = (your model):Clone()
		game.Players.LocalPlayer.Character = model
		model:SetPrimaryPartCFrame(location)
		model.Parent = game.Workspace
		for i, v in pairs(game.ReplicatedStorage:GetChildren()) do
			if v == character then
				plrcheck = 1
			end
		end
		if plrcheck == 0 then
			character.Parent = game.ReplicatedStorage
		end

		model.Humanoid.Died:Connect(function()
			game.Players.LocalPlayer.Character = character
			character.Humanoid.Health = 0
			character.Parent = game.Workspace
			character.HumanoidRootPart.CFrame = (part that is far away).CFrame
			wait(6)
			model:Destroy()
			debounce = false
		end)
	end
end)

Thats nice that your saving it incase someone needs it but heres the new post: How can I change the players bodycolor using gui buttons and save it incase they teleport to another place/level or until they die - #2 by DrKittyWaffles