Mannequin with Try On Feature

I am creating a clothing mannequin that lets players try on the displayed shirt and pants. This is being done with ClickDetectors in the Left Arm and Left Leg. When I test out applying one of the clothing items, it applies both at the same time instead of one exclusively.

Video

Are the ClickDetectors colliding with each other? How can I test for it?

2 Likes

Can we see the script you are using? So we can help better on the problem

Possibily both you are using for shirt and pants

Apologies for the delay. Here is my mess of a script:

local displayModel = script.Parent

for _, v in pairs(displayModel:GetChildren()) do
	if v.Name == "Left Arm" or v.Name == "Left Leg" then
		local ClickDetector = Instance.new("ClickDetector")
		ClickDetector.MaxActivationDistance = 10
		ClickDetector.Name = "Detector"
		ClickDetector.Parent = v
	end
end

displayModel["Left Arm"].Detector.MouseHoverEnter:Connect(function(playerWhoHovered)
	local tryShirt = Instance.new("BillboardGui")
	tryShirt.AlwaysOnTop = true
	tryShirt.Name = "Try On Shirt"
	tryShirt.Adornee = displayModel["Left Arm"]
	tryShirt.Size = UDim2.new(0,100,0,25)
	tryShirt.Parent = playerWhoHovered.PlayerGui
	
	local textLabel = Instance.new("TextLabel")
	textLabel.BackgroundColor3 = Color3.fromRGB(135,135,135)
	textLabel.BorderColor3 = Color3.fromRGB(27,42,53) 
	textLabel.BorderMode = "Inset"
	textLabel.BorderSizePixel = 3
	textLabel.Size = UDim2.new(0,100,0,25)
	textLabel.Text = "Try On Shirt"
	textLabel.TextSize = 12
	textLabel.Parent = tryShirt
end)

displayModel["Left Leg"].Detector.MouseHoverEnter:Connect(function(playerWhoHovered)
	local tryPants = Instance.new("BillboardGui")
	tryPants.AlwaysOnTop = true
	tryPants.Name = "Try On Pants"
	tryPants.Adornee = displayModel["Left Leg"]
	tryPants.Size = UDim2.new(0,100,0,25)
	tryPants.Parent = playerWhoHovered.PlayerGui
	
	local textLabel = Instance.new("TextLabel")
	textLabel.BackgroundColor3 = Color3.fromRGB(135,135,135) --Color of the Gui Background, must be an RGB number value
	textLabel.BorderColor3 = Color3.fromRGB(27,42,53)  -- Color of the border, must be an RGB number value
	textLabel.BorderMode = "Inset"
	textLabel.BorderSizePixel = 3 -- border width
	textLabel.Size = UDim2.new(0,100,0,25)
	textLabel.Text = "Try On Pants"
	textLabel.TextSize = 12
	textLabel.Parent = tryPants
end)

displayModel["Left Arm"].Detector.MouseHoverLeave:Connect(function(playerWhoHovered)
	playerWhoHovered.PlayerGui:FindFirstChild("Try On Shirt"):Destroy()
end)

displayModel["Left Leg"].Detector.MouseHoverLeave:Connect(function(playerWhoHovered)
	playerWhoHovered.PlayerGui:FindFirstChild("Try On Pants"):Destroy()
end)

displayModel["Left Arm"].Detector.MouseClick:Connect(function(playerWhoClicked)
	local shirtid = displayModel.Shirt.ShirtTemplate
	local player = playerWhoClicked.Character
	player.Shirt.ShirtTemplate = shirtid
end)

displayModel["Left Arm"].Detector.MouseClick:Connect(function(playerWhoClicked)
	local pantsid = displayModel.Pants.PantsTemplate
	local player = playerWhoClicked.Character
	player.Pants.PantsTemplate = pantsid
end)

Look at your code. You used the same click dector twice for the pants and shirt.
This is the code that you wrote. You can see “Left Arm” is used twice for the shirt and pants. Changing this should fix your problem!

displayModel["Left Arm"].Detector.MouseClick:Connect(function(playerWhoClicked)
	local shirtid = displayModel.Shirt.ShirtTemplate
	local player = playerWhoClicked.Character
	player.Shirt.ShirtTemplate = shirtid
end)

displayModel["Left Arm"].Detector.MouseClick:Connect(function(playerWhoClicked)
	local pantsid = displayModel.Pants.PantsTemplate
	local player = playerWhoClicked.Character
	player.Pants.PantsTemplate = pantsid
end)
1 Like

Ah shoot! Thanks! I guess it’s true the brain makes you believe what you wrote is correct.

1 Like

Had that happen to me multiple times. And then when I realise it, I just start questioning myself with everything I scripted. Lol

1 Like