Why is the clickdetector not changing my outfit again after reset

So I noticed that after I reset I can get the outfit again when I try to click the outfit again. Is this due to the character not being loaded fully yet? or maybe its due to something else?

function ShopClotheCamTween()
	
	--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 ClotheModel2ShirtTemplate = 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 LeftClickToBuy = script.Parent:WaitForChild("BuyGui"):WaitForChild("Display"):WaitForChild("Left click to buy")
		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
			
			Character.Shirt.ShirtTemplate =ClotheModel1ShirtTemplate
			Character.Pants.PantsTemplate = ClotheModel1PantsTemplate
			--Dissconnect function 
		end)
		
	end)

The code you should be looking at is at the bottom

2 Likes

You want it so when a player resets, while they’re dead they cannot click any of the outfits?

2 Likes

So basically the first time I can get the outfit, but the second time after I reset I cant

1 Like

do you want them to be able to get it after they reset?

1 Like

Yeah I want them to still be able to get the outfit after they reset

1 Like

Is it due to the function and how it only runs once?? Or am I wrong?

1 Like

Make sure you add a character added function so it runs after they respawn. This could be your issue if you only use a player added function

1 Like

hmmm so inside of the clickdetector event I should add a player added function and a character added function?

1 Like

Its not seeming to work

	LeftClickToBuy.MouseButton1Click:Connect(function()
			--Need to make some CharacterAdded function
			local Player = game.Players
			Player.PlayerAdded:Connect(function()
				local Character = Player.CharacterAdded:Connect(function(Char)
					Char.Shirt.ShirtTemplate =ClotheModel1ShirtTemplate
					Char.Pants.PantsTemplate = ClotheModel1PantsTemplate
					--Dissconnect function 
				end)
			end)
			
		end)
		
	end)
1 Like