How to fix clickdetector bug

Can someone help me figure out why even when I click on the part with the click detector it doesnt even print v.Name

why are you endlessly declaring a new connection every 4th heartbeat

Try not running a local script from a workspace folder… move it to startergui or starterplayerscripts that handle local scripts.

its in startergui and still not working

Move it to starterplayerscripts and try as that place works better with click detectors.

in the while loop? or where in the script

image
Do you know what you’re doing here? You’re constantly creating a new RBXScriptConnection for the same objects which is definitely NOT how you use connections

Are you sure you’re clicking on the correct part? Does the cursor change at all when you hover your mouse over it?

1 Like

I dont understand what you mean by Im creating a new connection whats wrong with ti?

Events last forever until it’s disconnected or the object it’s bound to get destroyed. You do not need to create a new connection of the same function. You only need one.

local OrbsFolder = game.Workspace.OrbsFolder
local plr = game.Players.LocalPlayer


for i, v in pairs(OrbsFolder:GetChildren()) do
	v.ClickBox.ClickDetector.MouseClick:Connect(function()
		print(v.Name)
		v.Name = v.Name .. " Breaking"
		game.Workspace.CurrentBreak.Value = v.Name
	end)
end

This better?

It still wont print (v.Name) I dont kno why

ya and does it still not work?

Yep still broken, dont kno why

Did u move to starterplayerscripts?

That wont do anything else its just a new location

Yes it will, move it to StarterPlayerScripts

Also, it could be that the orbs didn’t load in time on the client and so the connections were never established

I did and it still wont work, Dont know

how could I fix that?? I have no clue

local OrbsFolder = game.Workspace:WaitForChild(“OrbsFolder”)