You are on page 1of 2

local function tw(target,changes,style,dir,tim)

game:GetService('TweenService'):Create(target,TweenInfo.new(tim,Enum.EasingStyle[st
yle],Enum.EasingDirection[dir]),changes):Play()
end

local player = game.Players.LocalPlayer;

player.CharacterAdded:Wait();

local StarterShirt = player.Character:WaitForChild("Shirt").ShirtTemplate;


local StarterPants = player.Character:WaitForChild('Pants').PantsTemplate;

for i,v in next, workspace.Mannequins:GetDescendants() do


if v:IsA('ClickDetector') and v.Parent.Name:lower() == "shirtsclickable" or
v.Parent.Name:lower() == "pantsclickable" then
v.MouseClick:Connect(function()
if player.PlayerGui:FindFirstChild("current") == nil then
if v.Parent.Name:lower() == "shirtsclickable" and
v.Parent.Parent.ShirtId.Value ~= 0 then
local Cloned =
player.PlayerGui:WaitForChild("template"):Clone();
Cloned.Parent = player.PlayerGui
Cloned.Name = "current"
Cloned.mainFrame.assetImage.Image =
"https://www.roblox.com/Thumbs/Asset.ashx?
width=420&height=420&assetId="..v.Parent.Parent.ShirtId.Value
Cloned.Enabled = true

if Cloned.mainFrame:FindFirstChild("tryonButton") ~= nil then

Cloned.mainFrame.tryonButton.MouseButton1Click:Connect(function()
if Cloned.mainFrame.tryonButton.Text == "TRY-ON" then
local success, er = pcall(function()

game.ReplicatedStorage.toggleTry:FireServer(v.Parent.Parent.Shirt.ShirtTemplate,
false)
end)

if success then
Cloned.mainFrame.tryonButton.Text = "TAKE-OFF"
end
elseif Cloned.mainFrame.tryonButton.Text == "TAKE-OFF"
then
local success, er = pcall(function()

game.ReplicatedStorage.toggleTry:FireServer(StarterShirt, false)
end)

if success then
Cloned.mainFrame.tryonButton.Text = "TRY-ON"
end
end
end)
end
elseif v.Parent.Parent.PantsId.Value ~= 0 and v.Parent.Name:lower()
== "pantsclickable" then
local Cloned =
player.PlayerGui:WaitForChild("template"):Clone();
Cloned.Parent = player.PlayerGui
Cloned.Name = "current"
Cloned.mainFrame.assetImage.Image =
"https://www.roblox.com/Thumbs/Asset.ashx?
width=420&height=420&assetId="..v.Parent.Parent.PantsId.Value
Cloned.Enabled = true

if Cloned.mainFrame:FindFirstChild("tryonButton") ~= nil then

Cloned.mainFrame.tryonButton.MouseButton1Click:Connect(function()
if Cloned.mainFrame.tryonButton.Text == "TRY-ON" then
local success, er = pcall(function()

game.ReplicatedStorage.toggleTry:FireServer(v.Parent.Parent.Pants.PantsTemplate,
true)
end)

if success then
Cloned.mainFrame.tryonButton.Text = "TAKE-OFF"
end
elseif Cloned.mainFrame.tryonButton.Text == "TAKE-OFF"
then
local success, er = pcall(function()

game.ReplicatedStorage.toggleTry:FireServer(StarterPants, true)
end)

if success then
Cloned.mainFrame.tryonButton.Text = "TRY-ON"
end
end
end)
end
end
end
end)
end
end

You might also like