Click detector not detecting click

https://gyazo.com/7868dc9b692c5fd184177f2657bd932c
Hello, so basically, when you click, it should give you a weapon… but it’s not even printing ‘hi’ when I click. any idea?
https://gyazo.com/f15da727dc59b54767537d0d12c0a04b
code:

for i,v in ipairs(workspace.Map.Chunk1.Crates:GetChildren()) do			
	objects[v] = false																																																								
	v.Moving.ClickDetector.MouseClick:Connect(function(plr)
	if objects[v] == false then
		objects[v] = true --Primary
		v.Moving.ClickDetector.Open:Play()
		v.Moving.Primary.Motor.MaxVelocity = 0.03
		v.Moving.Primary.Motor.DesiredAngle = -1.05
		v.Moving.Particle.Sparkles.Enabled = false
		v.CurrentWeapon:ClearAllChildren()
		
		local object = game.ReplicatedStorage.Weapons:FindFirstChild(SetupCrates())
		game.ReplicatedStorage.OOP.Notification:FireClient(plr, "You found "..object.Name)
	if object ~= "Nothing!" then
		if object then
			wait(0.3)
			local Click = Instance.new('ClickDetector', object)
			local new = object:Clone()
			local Value = Instance.new('StringValue', v.CurrentWeapon)
			Value.Name = "Type"
			Value.Value = game.ServerStorage:FindFirstChild(new.Name).Class.Value
		
			
		new.Parent =v.CurrentWeapon
	     new:MoveTo(v.GunSpawn.Position)
-- CLICK HERE
	 Click.MouseClick:Connect(function(Player)
		print('Ok!')
		local char = Characters[Player.UserId]
				if v.CurrentWeapon.Type.Value == "Primary" then
					char:SetPrimaryWeapon(new.Name)
				elseif  v.CurrentWeapon.Type.Value == "Secondary" then
					char:GiveSecondaryWeapon(new.Name)
				end
				new:Destroy()
				end)
					-- END 
	     for b,a in ipairs(new:GetChildren()) do
		  if a:IsA("BasePart") then
			spawn(function()
				print('Ok')
				TweenService:Create(a, TweenInfo.new(2), {Position = a.Position + Vector3.new(0,1,0)}):Play()
				end)
			end
		end
		delay(4, function()
			CleanUp(v)
			end)
		end
	end
	end
end)
end

Basically when you click it should print “Ok!” But it’s not.

1 Like

I see that you create a new gun object, but link the clickdetector to the old one. Try creating the click detector after you create the new gun object and then adding the event in.

local new = object:Clone()
local Click = Instance.new('ClickDetector', new)
2 Likes

What do you mean, I clone new gun object first?