How to fix clickdetector bug

its still not working i have no clue whats wrong

at this point can u just send us the place file so we can dissect your game

Send me the updated script please.

local OrbsFolder = game.Workspace:WaitForChild("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

place:

Star Simulator.rbxl (158.6 KB)

Your getting all of the children. That’s an issue because there is a script in that folder.

OHHH I know what i can do thanks

Or, you could check if v:IsA(“Group”)

local OrbsFolder = game.Workspace:WaitForChild("OrbsFolder")
local plr = game.Players.LocalPlayer


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

That’s good. Test if it works.

It does thanks for reminding me that I can do that

1 Like