So when I click an outift in the shop and go back into the shop to try to change my outfit it doesn’t change. Why could that be?
Video:
–LOCAL SCRIPT
function ShopClotheCamTween()
--Variables
local Char = game:GetService("Players").LocalPlayer.Character
local LeftClickToBuy = script.Parent:WaitForChild("BuyGui"):WaitForChild("Display"):WaitForChild("Left click to buy")
--TweenStuff
--CAMERAS
local ClotheCam1 = CameraFolder:WaitForChild("ClotheCam1")
local ClotheCam2 = CameraFolder:WaitForChild("ClotheCam2")
local ClotheCam3 = CameraFolder:WaitForChild("ClotheCam3")
--CLOTHES
local Clothes1 = ClothesFolder:WaitForChild("Clothe1")
local Clothe2 = ClothesFolder:WaitForChild("Clothe2")
local Clothe3 = ClothesFolder:WaitForChild("Clothe3")
local ClotheModel1ShirtTemplate = ClothesFolder:WaitForChild("ClotheModel1").Shirt.ShirtTemplate
local ClotheModel2ShirtTemplate = ClothesFolder:WaitForChild("ClotheModel2").Shirt.ShirtTemplate
local ClotheModel3ShirtTemplate = ClothesFolder:WaitForChild("ClotheModel3").Shirt.ShirtTemplate
local ClotheModel1PantsTemplate = ClothesFolder:WaitForChild("ClotheModel1").Pants.PantsTemplate
local ClotheModel2PantsTemplate = ClothesFolder:WaitForChild("ClotheModel2").Pants.PantsTemplate
local ClotheModel3PantsTemplate = ClothesFolder:WaitForChild("ClotheModel3").Pants.PantsTemplate
---CLICKDETECTORS
local ClickDetector1 = Instance.new("ClickDetector")
ClickDetector1.Name = "ClickDetector1"
ClickDetector1.Parent = Clothes1
local ClickDetector2 = Instance.new("ClickDetector")
ClickDetector2.Name = "ClickDetector2"
ClickDetector2.Parent = Clothe2
local ClickDetector3 = Instance.new("ClickDetector")
ClickDetector3.Name = "ClickDetector3"
ClickDetector3.Parent = Clothe3
local info = TweenInfo.new(1,Enum.EasingStyle.Sine, Enum.EasingDirection.Out,0,false,0)
local BuyGuiGoal = {Visible = true}
local BuyGuiTweenCreated = tweenservice:Create(BuyGuiFrame, info, BuyGuiGoal)
ClickDetector1.MouseClick:Connect(function(player)
stepped:Disconnect()
--Variables
local goal = {CFrame = ClotheCam1.CFrame}
local ClotheCam1Tween = tweenservice:Create(Camera, info, goal)
-- Coding
ClotheCam1Tween:Play()
BuyGui.Enabled = true
BuyGuiTweenCreated:Play()
BuyGuiFrame:WaitForChild("Clothing Name").Text = "Firebending Robe"
BuyGuiFrame:WaitForChild("Cost").Text = "50"
LeftClickToBuy.MouseButton1Click:Connect(function()
--Need to make some CharacterAdded function
local Data = {Clothing = "Clothing1"}
Dialogueremote:FireServer(Data)
end)
end)
ClickDetector2.MouseClick:Connect(function(player)
stepped:Disconnect()
local goal = {CFrame = ClotheCam2.CFrame}
local ClotheCam2Tween = tweenservice:Create(Camera, info, goal)
ClotheCam2Tween:Play()
BuyGui.Enabled = true
BuyGuiTweenCreated:Play()
BuyGuiFrame:WaitForChild("Clothing Name").Text = "Firebending Kimono"
BuyGuiFrame:WaitForChild("Cost").Text = "75"
LeftClickToBuy.MouseButton1Click:Connect(function()
--Need to make some CharacterAdded function
local Data = {Clothing = "Clothing2"}
Dialogueremote:FireServer(Data)
end)
end)
ClickDetector3.MouseClick:Connect(function(player)
stepped:Disconnect()
local goal = {CFrame = ClotheCam3.CFrame}
local ClotheCam3Tween = tweenservice:Create(Camera, info, goal)
ClotheCam3Tween:Play()
BuyGuiTweenCreated:Play()
BuyGui.Enabled = true
BuyGuiFrame:WaitForChild("Clothing Name").Text = "Firebending Red"
BuyGuiFrame:WaitForChild("Cost").Text = "100"
--[[Char.Shirt.ShirtTemplate = ClotheModel3ShirtTemplate
Char.Pants.PantsTemplate = ClotheModel3PantsTemplate]]
LeftClickToBuy.MouseButton1Click:Connect(function()
--Need to make some CharacterAdded function
local Data = {Clothing = "Clothing3"}
Dialogueremote:FireServer(Data)
end)
end)
end
– Server Script
DialogueRemote.OnServerEvent:Connect(function(player, Data)
--Clothing
local ClothesFolder = game.Workspace.Shop.Clothes
local ClotheModel1ShirtTemplate = ClothesFolder:WaitForChild("ClotheModel1").Shirt.ShirtTemplate
local ClotheModel2ShirtTemplate = ClothesFolder:WaitForChild("ClotheModel2").Shirt.ShirtTemplate
local ClotheModel3ShirtTemplate = ClothesFolder:WaitForChild("ClotheModel3").Shirt.ShirtTemplate
local ClotheModel1PantsTemplate = ClothesFolder:WaitForChild("ClotheModel1").Pants.PantsTemplate
local ClotheModel2PantsTemplate = ClothesFolder:WaitForChild("ClotheModel2").Pants.PantsTemplate
local ClotheModel3PantsTemplate = ClothesFolder:WaitForChild("ClotheModel3").Pants.PantsTemplate
local Player = game:GetService("Players")
local Char = player.Character
if Data.Clothing == "Clothing1" then
for clothingType, clothingTemplate in {Shirt = ClotheModel1ShirtTemplate, Pants = ClotheModel1PantsTemplate} do
pcall(function()
Char:FindFirstChildWhichIsA(clothingType)[clothingType .. "Template"] = clothingTemplate
end)
end
elseif Data.Clothing == "Clothing2" then
for clothingType2, clothingTemplate2 in {Shirt = ClotheModel2ShirtTemplate, Pants = ClotheModel2PantsTemplate} do
pcall(function()
Char:FindFirstChildWhichIsA(clothingType2)[clothingType2 .. "Template"] = clothingTemplate2
end)
end
elseif Data.Clothing == "Clothing3" then
for clothingType3, clothingTemplate3 in {Shirt = ClotheModel3ShirtTemplate, Pants = ClotheModel3PantsTemplate} do
pcall(function()
Char:FindFirstChildWhichIsA(clothingType3)[clothingType3 .. "Template"] = clothingTemplate3
end)
end
end
end)