Script wont fire on part click?

I have a clickdetector part which doesnt fire for some reason when I click it, I dont know why this is happening as it doesn’t output and error and doesn’t output the print() I put in help would be appreciated thank you!,

The script itself :

The script and the children :
image

The code :

local debounce = false
local button = script.Parent

button.ClickDetector.MouseClick:Connect(function(player)
	if player.Character.StatusEffects.InGroup == true and debounce == false then
		for i, d in pairs (game.ReplicatedStorage.Parties:GetDescendants()) do
			if d:IsA("StringValue") and d.Value == player.Name then
				debounce = true
				debounce = false
				print("works")
	elseif player.Character.StatusEffects.InGroup == false and debounce == false then
			debounce = true
			local humanoidrootpart = player.Character:FindFirstChild("HumanoidRootPart")
			humanoidrootpart.CFrame = workspace.Area.Waterfall.Boss.UndyneArena.PlayerPoint.CFrame
			wait(0.1)
			debounce = false
			print("works")
			end
		end
	end
end)

Help would be appreciated thank you!

It might just be me, but the script looks like it’s disabled.
Is it?

1 Like

Have you tried putting the print() outside of all if statements and loops? The problem could be with the conditions not being satisfied rather than the function not firing.

No its the one that isnt disabled.

Yeah I have but I still don’t know why it doesnt work.

put something on the MouseClick function

local debounce = false
local button = script.Parent

button.ClickDetector.MouseClick:Connect(function(player)
	print("click")
	if player.Character.StatusEffects.InGroup == true and debounce == false then
		for i, d in pairs (game.ReplicatedStorage.Parties:GetDescendants()) do
			if d:IsA("StringValue") and d.Value == player.Name then
				debounce = true

				task.wait(0.1)

				debounce = false
			elseif player.Character.StatusEffects.InGroup == false and debounce == false then
				debounce = true

				player.Character:PivotTo(workspace.Area.Waterfall.Boss.UndyneArena.PlayerPoint.CFrame)

				task.wait(0.1)
				debounce = false
				print("works")
			end
		end
	end
end)

it fires, so its either the requirements for the if function, but I dont know why ill see if its the debounce part.
image

nvm i found the problem

local debounce = false
local button = script.Parent

button.ClickDetector.MouseClick:Connect(function(player)
	local continueToBossfight = true
	
	if debounce == false then
		for i, d in pairs (game.ReplicatedStorage.Parties:GetDescendants()) do
			if d:IsA("StringValue") and d.Value == player.Name then
				continueToBossfight = false
			end
		end
		
		if continueToBossfight then
			player.Character:PivotTo(workspace.Area.Waterfall.Boss.UndyneArena.PlayerPoint.CFrame)
		end
		
		debounce = true
		
		task.wait(0.1)

		debounce = false
	end
end)

Where does it define the value though?

you forgot to put .Value on this line

local debounce = false
local button = script.Parent

button.ClickDetector.MouseClick:Connect(function(player)
	local continueToBossfight = true

	if debounce == false then
		if player.Character.StatusEffects.InGroup == true then
			for i, d in pairs (game.ReplicatedStorage.Parties:GetDescendants()) do
				if d:IsA("StringValue") and d.Value == player.Name then
					continueToBossfight = false
				end
			end
		end

		if continueToBossfight and player.Character.StatusEffects.InGroup.Value == false then
			player.Character:PivotTo(workspace.Area.Waterfall.Boss.UndyneArena.PlayerPoint.CFrame)
		end

		debounce = true

		task.wait(0.1)

		debounce = false
	end
end)
1 Like

bruh lol, I’m stupid my bad thank you