Player Not Animating (urgent)

I have an issue with localrscripts not functioning inside a player model. I have no idea how to explain it since im dumbfounded. Heres the code that assigns a player model to a character. Local scripts don’t work inside the script assigned playermodel.

Serverscript

local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local chars = ServerStorage:FindFirstChild("Chars")
local usedChars = ServerStorage:FindFirstChild("UsedChars")
local remotes = ReplicatedStorage:FindFirstChild("Remotes")
local gui = script.ScreenGui

Players.PlayerAdded:Connect(function(player)
	
	local selectedCharacter = chars:GetChildren()[math.random(1,#chars:GetChildren())]

	selectedCharacter.Parent = usedChars
	
	player.Destroying:Connect(function()
		selectedCharacter.Parent = chars
	end)
	
	player.CharacterAdded:Connect(function()
		local pchar = selectedCharacter:Clone()
		pchar.Name = player.Name
		pchar.Parent = workspace
		local oldchar = player.Character
		pchar:MoveTo(oldchar:FindFirstChild("HumanoidRootPart").Position)
		player.Character = pchar
		task.wait()
		oldchar:Destroy()
		remotes.RebindCam:FireClient(player,pchar:FindFirstChild("Humanoid"))
		local newgui = gui:Clone()
		newgui = player.PlayerGui
	end)
	
end)
  
2 Likes