Click detector is not working

Ok first thing is i use my value num on click detect and pair (u can see in 8 line)
What i want is if my num are one i only can click on first button

here pic/code

wait(1)
local Md = require(game:GetService("ReplicatedStorage").Math)
local Main = script.Parent.Parent
local char = game:GetService("Players").LocalPlayer.Character
local hum = char:FindFirstChild("Humanoid")
local root = char:WaitForChild("HumanoidRootPart")
local num = 1
local cd  = game:GetService("Workspace").Num.Button[num].cds

while true do
	wait(1)
	print(cd.Parent.Name)
	print(cd)
end

function nigsdsga()
	script.Parent.TextLabel.Text = Md[num]["Qu:Name"]
	script.Parent.A.Text = Md[num]["A:Ch"]["A:Text"]
	script.Parent.B.Text = Md[num]["B:Ch"]["B:Text"]
	script.Parent.C.Text = Md[num]["C:Ch"]["C:Text"]
	script.Parent.D.Text = Md[num]["D:Ch"]["D:Text"]
end

function explosion()
	local ex = Instance.new("Explosion")
	ex.Parent = workspace
	ex.Position = root.Position
end

nigsdsga()

cd.MouseClick:Connect(function()
	print("FORTHELOVEOFGOD")
	if hum.Health > 0 then
		print(cd.Parent.Name)
		Main.Enabled = true
	end
end)

script.Parent.A.Activated:Connect(function()
	if Md[num]["A:Ch"]["Isto/Fault"] == true then
		num += 1
		nigsdsga()
		Main.Enabled = false
	else
		explosion()
	end
end)

script.Parent.B.Activated:Connect(function()
	if Md[num]["B:Ch"]["Isto/Fault"] == true then
		num += 1
		nigsdsga()
		Main.Enabled = false
	else
		explosion()
	end
end)

script.Parent.C.Activated:Connect(function()
	if Md[num]["C:Ch"]["Isto/Fault"] == true then
		num += 1
		nigsdsga()
		Main.Enabled = false
	else
		explosion()
	end
end)

script.Parent.D.Activated:Connect(function()
	if Md[num]["D:Ch"]["Isto/Fault"] == true then
		num += 1
		nigsdsga()
		Main.Enabled = false
	else
		explosion()
	end
end)

image

i try print out a name and it work but not the click detector

This is causing your script to not work. This loop is all it gets to.

Bro…i think my brain just dumb :edit nvm it still not work

wait(1)
local Md = require(game:GetService("ReplicatedStorage").Math)
local Main = script.Parent.Parent
local char = game:GetService("Players").LocalPlayer.Character
local hum = char:FindFirstChild("Humanoid")
local root = char:WaitForChild("HumanoidRootPart")
local num = 1
local cd  = game:GetService("Workspace").Num.Button[num].cds

function nigsdsga()
	script.Parent.TextLabel.Text = Md[num]["Qu:Name"]
	script.Parent.A.Text = Md[num]["A:Ch"]["A:Text"]
	script.Parent.B.Text = Md[num]["B:Ch"]["B:Text"]
	script.Parent.C.Text = Md[num]["C:Ch"]["C:Text"]
	script.Parent.D.Text = Md[num]["D:Ch"]["D:Text"]
end

function explosion()
	local ex = Instance.new("Explosion")
	ex.Parent = workspace
	ex.Position = root.Position
end

nigsdsga()

cd.MouseClick:Connect(function()
	print("FORTHELOVEOFGOD")
	if hum.Health > 0 then
		print(cd.Parent.Name)
		Main.Enabled = true
	end
end)

script.Parent.A.Activated:Connect(function()
	if Md[num]["A:Ch"]["Isto/Fault"] == true then
		num += 1
		nigsdsga()
		Main.Enabled = false
	else
		explosion()
	end
end)

script.Parent.B.Activated:Connect(function()
	if Md[num]["B:Ch"]["Isto/Fault"] == true then
		num += 1
		nigsdsga()
		Main.Enabled = false
	else
		explosion()
	end
end)

script.Parent.C.Activated:Connect(function()
	if Md[num]["C:Ch"]["Isto/Fault"] == true then
		num += 1
		nigsdsga()
		Main.Enabled = false
	else
		explosion()
	end
end)

script.Parent.D.Activated:Connect(function()
	if Md[num]["D:Ch"]["Isto/Fault"] == true then
		num += 1
		nigsdsga()
		Main.Enabled = false
	else
		explosion()
	end
end)

Question, why do you have a wait above your Script?

my game is too slow to load a char even i waitforchild and i too lazy to use untril

You know, you can just do this:

local Player = game.Players.LocalPlayer
local char = Player.Character or Player.CharacterAdded:Wait()

Is anything printing when you click the part?

1 Like

No i doesn’t see any print out

Okay, try also printing right on the top of the script to see if it runs at all. If it does print, place a breakpoint at the start of the script, and start debugging. This is so you can see if your script is halting anywhere.

here it show me this
image

That doesn’t show anything. I mean, use breakpoints to stop the script when it gets to it, then you can manually step Lua through the script to see where it goes and doesn’t go. If it doesn’t run the MouseEnter connection, then you can find out what is causing that.

1 Like

at first i don’t even know how to use or what it is (breakpoints) ty it’s open my eye

What was causing the issue in your script?

i don’t know i have no clue
let rest and i’m gotta fix it next day