Help with GUI and animation

I’m trying to make a character selection GUI

Screen Shot 2022-06-29 at 4.40.46 PM

this is how it is organized but there’s a script that generates the characters

LocalScript

local SetSubject = game.ReplicatedStorage:WaitForChild("setSubject")

function onEvent_SetSubject(Humanoid)
	workspace.CurrentCamera.CameraSubject = Humanoid
end

SetSubject.OnClientEvent:Connect(onEvent_SetSubject)

Normal script

local Player = script.Parent.Parent.Parent
local Content = script.Parent.mainFrame.ScrollingFrame
local Characters = game.ReplicatedStorage.characters
local SetSubject = Characters.Parent.setSubject

for index,item in pairs(Characters:GetChildren()) do
	if item:FindFirstChild("Humanoid") then
		local ViewportFrame = Instance.new("ViewportFrame")
		ViewportFrame.Parent = Content
		ViewportFrame.BackgroundTransparency = 1

		local Button = Instance.new("TextButton")
		Button.Parent = ViewportFrame
		Button.Position = UDim2.new(0,0,1,0)
		Button.Size = UDim2.new(1,0,0,15)
		Button.BorderSizePixel = 0
		Button.BackgroundColor3 = Color3.fromRGB(255,255,255)
		Button.Text = "Spawn"
		Button.TextScaled = true

		local Preview = item:Clone()
		Preview.Parent = ViewportFrame

		local Camera = Instance.new("Camera")
		Camera.Parent = ViewportFrame
		Camera.CFrame = Preview.Head.CFrame + Preview.Head.CFrame.LookVector * 5
		Camera.CFrame = CFrame.new(Camera.CFrame.Position,Preview.Head.Position)

		ViewportFrame.CurrentCamera = Camera

		Button.MouseButton1Down:Connect(function()
			script.Parent.Enabled = false
			local ChosenCharacter = item:Clone()
			local CurrentCharacter = Player.Character
			local LocalScripts = {}

			for index2,item2 in pairs(game.StarterPlayer.StarterCharacterScripts:GetChildren()) do
				if item2:IsA('LocalScript') then
					table.insert(LocalScripts,item2:Clone())
				else
					item2:Clone().Parent = ChosenCharacter
				end
			end

			CurrentCharacter.Health:Clone().Parent = ChosenCharacter
			table.insert(LocalScripts,CurrentCharacter.Animate:Clone())		
			ChosenCharacter.Parent = workspace
			Player.Character = ChosenCharacter
			for index2,item2 in pairs(LocalScripts) do
				item2.Parent = ChosenCharacter
			end	
			SetSubject:FireClient(Player,ChosenCharacter.Humanoid)

			local Connection

			local function onDied()
				wait(game.Players.RespawnTime)
				Player:LoadCharacter()
				script.Parent.Enabled = true
				if Connection then
					Connection:Disconnect()
				end
			end

			Connection = ChosenCharacter.Humanoid.Died:Connect(onDied)

		end)

	end
end

But the characters only show Studio

IN STUDIO

IN GAME

that’s not the only problem the character moves without animation

Please any help would be greatly appreciated

any help please still haven’t found answers

It looks like you’re using regular scripts rather than local scripts. You need to use local scripts so that they run on the client (instead of the server).

i switched to local script an error popped up

Read what it says; its obvious. The FireClient() api will only work on server scripts. Use FireServer()

  	SetSubject:FireClient(Player,ChosenCharacter.Humanoid)

@2jammers

I switched these to

SetSubject.OnServerEvent:Connect(onEvent_SetSubject)

and

  	SetSubject: FireServer(Player,ChosenCharacter.Humanoid)

this happened

are you still there please help with this

Did you even bother to read the error? It’s pretty self explanitory.

so what do I do switch to a regular script??

Change the code in the script so you don’t call FireClient / OnServerEvent

what do you mean?? what do i do

are you still there please help with this

hey I switched to a normal script and there were no errors but it did not work the character was my character it did not switch to the character in the gui and the scroll dispersed

hey I switched to a normal script and there were no errors but it did not work the character was my character it did not switch to the character in the gui and the scroll dispersed

All of the GUI stuff needs to be handled by local scripts as has been said before.

The server script will handle spawning in / assigning characters.

so do I brake the script into halfs???

and also wants wrong with the animations when walking it walks like a block

Whatever logic you have for applying the new character isn’t properly handling the normal animation script.

so how do I fix it?? how do I properly handle it??

CurrentCharacter.Health:Clone().Parent = ChosenCharacter
table.insert(LocalScripts,CurrentCharacter.Animate:Clone())
ChosenCharacter.Parent = workspace
Player.Character = ChosenCharacter
for index2,item2 in pairs(LocalScripts) do
item2.Parent = ChosenCharacter
end

here it adds the animate file into the new character what’s wrong??