Issue with Character Selection GUI

So I’ve been having troubles recently with my Character Selection GUI and I’m not sure why

Local Script: local gui = script.Parent

local player = game.Players.LocalPlayer

gui.MouseButton1Click:Connect(function()

gui.RemoteEvent:FireServer()

end)

ServerScript: local gui = script.Parent

gui.RemoteEvent.OnServerEvent:Connect(function(player)
local char = player.Character
local change = game.ServerStorage.CharacterDummy:Clone()
change.Parent = workspace
player.Character = change
change.HumanoidRootPart.CFrame = char.HumanoidRootPart.CFrame
end)

I also get an error sayin Infinite Yield Possible so if anyone knows what I could delete, add or fix it would be really appreciated and have a great day :smiley:

1 Like

Can you elaborate what exact problems are you having? It would be helpful if you gave more insight on your current issue.

EDIT: After investigating a little I assume the problem is with the camera, correct? You will have to set workspace.CurrentCamera.CameraSubject to the designated Character’s humanoid for the camera to follow the character.

2 Likes

Well the problem is that if you want custom characters, you have to name it StarterCharacter and put it somewhere, Im 80% sure that you put it in StarterPlayer, so, when you clone the model/customcharacter, make sure to parent it to StarterPlayer when it gets cloned, then reset the player, then it should work.

Easy fix is just to parent it to StarterPlayer instead of workspace, I tested it and it works without the camera subject changing.
So the serverscript should be:

local gui = script.Parent

gui.RemoteEvent.OnServerEvent:Connect(function(player)
	local char = player.Character
	local change = game.ServerStorage.StarterCharacter:Clone() --make sure to name your custom character "StarterCharacter" or else it wont work.
	change.Parent = game.StarterPlayer
	player.Character = change
	change.HumanoidRootPart.CFrame = char.HumanoidRootPart.CFrame
end)

video showing it working:

1 Like

Thanks. foodislife! It worked but maycoleee how would I set it the camera to follow the character?
Edit: Nvm i got it