MouseButton1Click:Connect(function() won't work even after changed to Activated

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want it to enable the customization gui after selecting gender.
  2. What is the issue? Include screenshots / videos if possible!
    clicking on the button for male and female does nothing
    image
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

Tried changing MouseButton1Click to Activated, still won’t work.

Full script:

local GUI = script.Parent
local GenderFrame = GUI:WaitForChild("GenderFrame")
local Customization = GUI:WaitForChild("Customization")

local Event = game.ReplicatedStorage

local Gender

local SkinValue = 1
local FaceValue = 1
local HairValue = 1

local Finish = GUI:WaitForChild("Finish")
local Hover = script.Hover

local Mouse = game.Players.LocalPlayer:GetMouse()
local C1 = false

GUI:GetPropertyChangedSignal("Enabled"):Connect(function()
	if GUI.Enabled == true then
		local Camera = workspace.CurrentCamera
		Camera.CameraType = Enum.CameraType.Scriptable
		Camera.CFrame = workspace.CameraResources.DummyCamera.CFrame
	else
		local Camera = workspace.CurrentCamera
		if Camera.CameraType == Enum.CameraType.Scriptable then
		end
	end
end)

local Face = {
	[1] = "Default",
	[2] = "Dont wake me up",
	[3] = "Awkard Eyeroll",
	[4] = "Bad News Face",
	[5] = "Furious George",
	[6] = "George Nouveau",
	[7] = "Huh?",
	[8] = "Mad Face",
	[9] = "Nervous",
	[10] = "Not sure if...",
	[11] = "Rage Face",
	[12] = "Sad Face",
	[13] = "Smug",
	[14] = "Stink Eye",
	[15] = "Sweating",
	[16] = "Tired Face",	
}

local FemaleFace = {
	[1] = "Blue Galaxy Face",
	[2] = "Pink Galaxy Face",
	[3] = "Green Galaxy Face",
	[4] = "Freckles Face",
	[5] = "Concerned",
	[6] = "Purple Galaxy Face",
	[7] = "Sad Face",
	[8] = "Smiling Girl",
	[9] = "Kind Face",
	[10] = "Happy Face",
	[11] = "Miss Scarlet",
	[12] = "Err...",
}

local Skins = {
	[1] = "Skin1",
	[2] = "Skin2",
	[3] = "Skin3",
	[4] = "Skin4",
	[5] = "Skin5",
	[6] = "Skin6",
	[7] = "Skin7",
	[8] = "Skin8",
	[8] = "Skin9",
}

local MaleHairs = {
	[1] = "Default",
	[2] = "Chestnut Style",
	[3] = "Messy Hair",
	[4] = "Ravenhaired Charmer",
	[5] = "Stylish Brown Hair",
}

local FemaleHairs = {
	[1] = "Black and Red",
	[2] = "Platinum Messy Buns",
	[3] = "Cinnamon Hair",
	[4] = "Fro double Buns in Black",
	[5] = "Black Messy Bun",
}

local Arrows = {
	"Left",
	"Right",
}

local Genders = {
	"Male",
	"Female",
}

function UpdateHair(Value)
	if Gender == "Female" then
		local Hair = FemaleHairs[Value]
		local Object = game.ReplicatedStorage.Customization.Hairs:WaitForChild(Hair):Clone()
		local Dummy = game.Workspace.CameraResources.Dummy:WaitForChild("StarterCharacter")
		for i,v in pairs(Dummy:GetChildren()) do
			if v.ClassName == "Accessory" then
				v.Handle.Transparency = 1
			end
		end
		repeat wait() until Dummy:FindFirstChild(Object.Name)
		Dummy[Object.Name].Handle.Transparency = 0
	elseif Gender == "Male" then
		local Hair = MaleHairs[Value]
		local Object = game.ReplicatedStorage.Customization.Hairs:WaitForChild(Hair):Clone()
		local Dummy = game.Workspace.CameraResources.Dummy:WaitForChild("StarterCharacter")
		for i,v in pairs(Dummy:GetChildren()) do
			if v.ClassName == "Accessory" then
				v.Handle.Transparency = 1
			end
		end
		repeat wait() until Dummy:FindFirstChild(Object.Name)
		Dummy[Object.Name].Handle.Transparency = 0
	end
end

function UpdateFace(Value)
	local Place = game.ReplicatedStorage.Customization.Faces
	local FaceDecal
	if Gender == "Male" then
		FaceDecal = Place:WaitForChild(Face[Value])
	else
		FaceDecal = Place:WaitForChild(FemaleFace[Value])		
	end
	if FaceDecal then
		local Dummy = game.Workspace.CameraResources.Dummy:WaitForChild("StarterCharacter")
		Dummy.Head.face.Texture = FaceDecal.Texture
	end
end

function UpdateSkin(Value)
	local Dummy = game.Workspace.CameraResources.Dummy:WaitForChild("StarterCharacter")
	local BodyColor = Dummy:WaitForChild("Body Colors")
	local Tone = game.ReplicatedStorage.Customization.Skins:WaitForChild(Skins[Value])
	BodyColor.HeadColor = Tone.HeadColor
	BodyColor.TorsoColor = Tone.TorsoColor
	BodyColor.LeftArmColor = Tone.LeftArmColor
	BodyColor.RightArmColor = Tone.RightArmColor
	BodyColor.LeftLegColor = Tone.LeftLegColor
	BodyColor.RightLegColor = Tone.RightLegColor
end

UpdateSkin(SkinValue)
UpdateHair(HairValue)
Customization.Skin.TextLabel.Text = Skins[SkinValue]
Customization.Face.TextLabel.Text = Face[FaceValue]
if Gender == "Female" then
	Customization.Hair.TextLabel.Text = FemaleHairs[FaceValue]
else
	Customization.Hair.TextLabel.Text = MaleHairs[FaceValue]
end

GenderFrame:WaitForChild("Male").Activated:Connect(function()
	Gender = Genders[1]
	GenderFrame.Visible = false
	Customization.Visible = true
	UpdateFace(FaceValue)
	Finish.Visible = true
	Hover:Play()
end)

GenderFrame:WaitForChild("Female").MouseButton1Click:Connect(function()
	Gender = Genders[2]
	GenderFrame.Visible = false
	Customization.Visible = true
	UpdateFace(FaceValue)
	Finish.Visible = true
	Hover:Play()
end)
--
Customization.Skin:WaitForChild(Arrows[1]).MouseButton1Click:Connect(function()
	if SkinValue == 1 then
		SkinValue = 9
	else
		SkinValue = SkinValue - 1
	end
	UpdateSkin(SkinValue)
	Hover:Play()
	Customization.Skin.TextLabel.Text = Skins[SkinValue]
end)

Customization.Skin:WaitForChild(Arrows[2]).MouseButton1Click:Connect(function()
	if SkinValue == 9 then
		SkinValue = 1
	else
		SkinValue = SkinValue + 1
	end
	UpdateSkin(SkinValue)
	Hover:Play()
	Customization.Skin.TextLabel.Text = Skins[SkinValue]
end)
--
Customization.Face:WaitForChild(Arrows[1]).MouseButton1Click:Connect(function()
	if Gender == "Male" then
		if FaceValue == 1 then
			FaceValue = 16
		else
			FaceValue = FaceValue - 1
		end
		Customization.Face.TextLabel.Text = Face[FaceValue]
	elseif Gender == "Female" then
		if FaceValue == 1 then
			FaceValue = 12
		else
			FaceValue = FaceValue - 1
		end		
		Customization.Face.TextLabel.Text = FemaleFace[FaceValue]
	end
	Hover:Play()
	UpdateFace(FaceValue)
end)

Customization.Face:WaitForChild(Arrows[2]).MouseButton1Click:Connect(function()
	if Gender == "Male" then
		if FaceValue == 16 then
			FaceValue = 1
		else
			FaceValue = FaceValue + 1
		end
		Customization.Face.TextLabel.Text = Face[FaceValue]
	elseif Gender == "Female" then
		if FaceValue == 12 then
			FaceValue = 1
		else
			FaceValue = FaceValue + 1
		end		
		Customization.Face.TextLabel.Text = FemaleFace[FaceValue]
	end
	Hover:Play()
	UpdateFace(FaceValue)
end)
--
Customization.Hair:WaitForChild(Arrows[1]).MouseButton1Click:Connect(function()
	if HairValue == 1 then
		HairValue = 5
	else
		HairValue = HairValue - 1
	end
	UpdateHair(HairValue)
	if Gender == "Female" then
		Customization.Hair.TextLabel.Text = FemaleHairs[HairValue]
	else
		Customization.Hair.TextLabel.Text = MaleHairs[HairValue]
	end
	Hover:Play()
end)

Customization.Hair:WaitForChild(Arrows[2]).MouseButton1Click:Connect(function()
	if HairValue == 5 then
		HairValue = 1
	else
		HairValue = HairValue + 1
	end
	UpdateHair(HairValue)
	if Gender == "Female" then
		Customization.Hair.TextLabel.Text = FemaleHairs[HairValue]
	else
		Customization.Hair.TextLabel.Text = MaleHairs[HairValue]
	end
	Hover:Play()
end)
--
Finish.MouseEnter:Connect(function()
	Hover:Play()
	Finish.Line:TweenSize(UDim2.new(1,0,0,1),"Out", "Quad", .2)
	C1 = true
end)

Finish.MouseButton1Click:Connect(function()
	Customization.Visible = false
	Finish.Visible = false
	GUI.Confirmation.Visible = true
end)

Finish.MouseLeave:Connect(function()
	Finish.Line:TweenSize(UDim2.new(0,0,0,1),"Out", "Quad", .2)
	C1 = false
end)
--
Mouse.Move:Connect(function()
	if C1 then
		Finish.Line:TweenSize(UDim2.new(1,0,0,1),"Out", "Quad", .2)
	elseif C1 == false then
		Finish.Line:TweenSize(UDim2.new(0,0,0,1),"Out", "Quad", .2)
	end
end)
--
GUI.Confirmation.Yes.MouseButton1Click:Connect(function()
	local Event = game.ReplicatedStorage.RemoteEvents.Customization.FinishInfo
	local Camera = workspace.CurrentCamera
	local Menu = script.Parent.Parent:WaitForChild("MainMenu")
	local Player = game.Players.LocalPlayer

	if Gender == "Male" then
		Event:FireServer(Skins[SkinValue], Face[FaceValue], MaleHairs[HairValue], Gender) -- skin, face, hair
	else
		Event:FireServer(Skins[SkinValue], FemaleFace[FaceValue], FemaleHairs[HairValue], Gender) -- skin, face, hair
	end
	GUI.Enabled = false
	Camera.CameraType = Enum.CameraType.Custom

	Hover:Play()
	--
	for i = 1, 0, -.01 do
		Menu.Theme.Volume = i
		wait(.01)
	end
	Menu.Theme.Volume = 0
	Menu:Destroy()
	--game.Lighting.Blur:Destroy()
	game.Lighting.SunRays:Destroy()
	Camera.CameraType = Enum.CameraType.Custom
	Camera.CameraSubject = Player.Character.Humanoid
	Player.PlayerGui:WaitForChild("Menu"):Destroy()
	Player.PlayerGui:SetTopbarTransparency(0.5)
	game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat,true)
	game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All,true)
	game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList,false)
	game.ReplicatedStorage.RemoteEvents.AutoSave:FireServer()
	game.ReplicatedStorage.RemoteEvents.UpdateCharacter:FireServer()
	Player.PlayerGui:WaitForChild("Stats").Enabled = true
end)

GUI.Confirmation.No.MouseButton1Click:Connect(function()
	Customization.Visible = true
	Finish.Visible = true
	GUI.Confirmation.Visible = false
end)

Hierachy:

It’s as if

MouseButton1Click:Connect(function()

Is being ignored upon being fired.

1 Like

Perhaps you could add various print()s to your script in between functions to see where it is not working, usually helps identify the location of the error.

1 Like

Addding print() will print nothing, unless I define the print in between (), so no point in adding that for where parts are working or not working yet.

Are there any errors? I am assuming not but just checking.

No errors or warnings in the console logs at all…

Did you add print() to the functions that fire when the buttons are clicked, unless you already tried that, also in the print, just add a short string to identify the section, like “Button1”.

Is this the line you are referring to? Or are not of them being called?

No, that’s after you finish making your character.

1 Like

I did add a print function upon firing MouseButton1:Click(function(), but it doesn’t print.

1 Like

Does everything before that work? And everything after the function?

Honestly, I don’t know anymore, the print doesn’t even print upon clicking on both Female and Male Gender button, however, I don’t think MouseButton1Click:Connect(function() is firing.

None of these MouseButton1Click:Connect(function() are firing? Try adding a print statement right before you call the function. Or have you already tried that?

I don’t think it’ll work either way.

1 Like

It might be WaitForChild, sometimes that will stop things entirely. I doubt this is true but try FindFirstChild. It has happened to me before.

You can play the game here too see what I mean:

1 Like

Nevermind, I fixed it myself. Solution found.

1 Like