Changing Character not working

Hello, I am trying to change a character via a local script

Everything is correct, but the character just reloads to my own avatar when I use the command.

Firing Event Script:

local allowedname = "omotashi"

game.Players.PlayerAdded:Connect(function(Player)
	Player.Chatted:Connect(function(chat)
		if chat =="!Brody" and Player.Name == allowedname then
			game.ReplicatedStorage.Brody:FireAllClients()
			print("Fired")
			
		else
			print("tried")
		end
	end)
end)

game.ReplicatedStorage.Brody.OnServerEvent:Connect(function(player, newBaby)
	player:LoadCharacter(newBaby)
end)

Local Usage Script:

game.ReplicatedStorage.Brody.OnClientEvent:Connect(function()
	local BrodyF = game.ReplicatedStorage:FindFirstChild("BrodyDude")
	local player = game.Players.LocalPlayer
	
	local oldchara = player.Character
	local customchara = BrodyF:Clone()
	customchara.Name = player.Name
	player.Character = customchara
	customchara.HumanoidRootPart.CFrame = workspace.SpawnLocation.CFrame + Vector3.new(0,3,0)
	
end)

Here is also a video on the character and what happens when you use the command

1 Like

Adding that there is no error, and it just loads my personal character

1 Like

You have to do this in a server script instead of a local script. You can just loop through all players and set their characters

local BrodyF = game.ReplicatedStorage:FindFirstChild("BrodyDude")
for _, p in pairs(game.Players:getPlayers()) do
	local newchar = BrodyF:Clone()
	local oldchar = p.Character
	local cframe = oldchar:GetPrimaryPartCFrame()

	p.Character = newchar
	newchar.Parent = workspace
	newchar:SetPrimaryPartCFrame(cframe)
	oldchar:Destroy()
end

I haven’t tested it, but it should work

1 Like