Script wont work when fired with remote

Hi,

I was making a face customization script until I ran into an issue. The script doesn’t work when fired by a remote event, and only works without one. Another thing I seemed to notice is that the script doesn’t work if a wait() is present.

Note: I’ve tried many fixes but none of them seem to work. There are also no errors.

local Players = game:GetService("Players")

local rs = game:GetService("ReplicatedStorage")

local Face = rs.Remotes.Face


Face.OnServerEvent:Connect(function()
	wait(1)
	game.Players.PlayerAdded:Connect(function(Client)
		Client.CharacterAdded:Connect(function(character)

			local Eyes = rs.Faces.Eyes:GetChildren()
			local randomEyes = Eyes[math.random(1, #Eyes)]

			local Part = randomEyes:Clone()
			--Part.Decal.Color3 = Color3.new(randomR, randomB, randomG)
			local Weld = Instance.new("WeldConstraint")
			if Client.Character then
				wait(0.5)
				Part.Position = Client.Character.Head.Position
				Part.Orientation = Client.Character.Head.Orientation
				Weld.Parent = Client.Character
				Part.Parent = Client.Character.Face
				Weld.Part0 = Client.Character.Head
				Weld.Part1 = Part


			else
				Client.CharacterAdded:Connect(function()
					wait(0.5)
					Part.Position = Client.Character.Head.Position
					Part.Orientation = Client.Character.Head.Orientation
					Weld.Parent = Client.Character
					Part.Parent = Client.Character.Face
					Weld.Part0 = Client.Character.Head
					Weld.Part1 = Part
				end)
			end
		end)
	end)
end)

What is the wait(1) supposed to do?

I have another script that the remote fires that deletes and creates a new folder. The face is then put in the folder.

And when is this event supposed to fire?

local plr = game.Players.LocalPlayer

local chr = plr.Character or plr.CharacterAdded:Wait()

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)	

local rs = game:GetService("ReplicatedStorage")

local Face = rs.Remotes.Face

local b = Instance.new("BoolValue")
b.Parent  = chr
b.Name = "Click"

script.Parent.Reroll.MouseEnter:Connect(function()
	script.Parent.Reroll.ImageLabel.ImageColor3 = Color3.fromRGB(100, 100, 100)
	script.Parent.Hover:Play()
end)

script.Parent.Reroll.MouseLeave:Connect(function()
	script.Parent.Reroll.ImageLabel.ImageColor3 = Color3.fromRGB(70, 70, 70)
end)

script.Parent.Reroll.MouseButton1Down:Connect(function()
	script.Parent.Sound:Play()
	chr:FindFirstChild("Click"):Destroy()
	game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
	game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, true)
	chr.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
	Face:FireServer()
	script.Parent:Destroy()
end)

Is this script supposed to change a character’s face when the RemoteEvent is fired? In that case, you don’t need the PlayerAdded to get the character. FireServer() already carries the player that fired the RemoteEvent.

local rs = game:GetService("ReplicatedStorage")
local Face = rs.Remotes.Face

Face.OnServerEvent:Connect(function(player)
	local character = workspace:FindFirstChild(player.Name)
	
	if(character) then
		local Eyes = rs.Faces.Eyes:GetChildren()
		local randomEyes = Eyes[math.random(1, #Eyes)]
		local Part = randomEyes:Clone()
		local Weld = Instance.new("WeldConstraint")
		
		Part.Position = character.Head.Position
		Part.Orientation = character.Head.Orientation
		Weld.Parent = character
		Part.Parent = character.Face
		Weld.Part0 = character.Head
		Weld.Part1 = Part
	end
end)

I found out the reason why I couldn’t change the face.

It’s because I had to delete the existing weld constraints and create new ones. :man_facepalming: