Paused for Debugging issue

I have this server script inside of ServerScriptService with this code

local CollectionService = game:GetService('CollectionService')
local ReplicatedStorage = game:GetService('ReplicatedStorage')

local LOG_HEALTH = 30

local function SetUpLog(log)
	local ClickDetector = Instance.new('ClickDetector', log)
	ClickDetector.MouseClick:Connect(function(player)
		print('Debug: Clicked on log')
		local hasLog = player:FindFirstChild('Values').hasLog
		if hasLog then
			if hasLog.Value ~= true then
				log:Destroy()
				hasLog.Value = true
			end
		end
	end)
end

for _, log in pairs(CollectionService:GetTagged('Log')) do
	SetUpLog(log)
end
CollectionService:GetInstanceAddedSignal('Log'):Connect(function(instance)
	SetUpLog(instance)
end)

for _, tree in pairs(CollectionService:GetTagged('Tree')) do
	local treeLog = tree:FindFirstChild('Log')
	if treeLog then
		local ClickDetector = Instance.new('ClickDetector', treeLog)
		local LogHealth = Instance.new('NumberValue', treeLog)
		LogHealth.Name = 'Health'
		LogHealth.Value = LOG_HEALTH
		ClickDetector.MouseClick:Connect(function(player)
			if LogHealth.Value > 1 then
				LogHealth.Value = LogHealth.Value - 6
				treeLog:FindFirstChild('HealthGui'):FindFirstChild('Health').Text = 'Health: ' .. LogHealth.Value
			else
				tree:Destroy()
				local LogToDrop = ReplicatedStorage.Items.Drops.Log:Clone()
				CollectionService:AddTag(LogToDrop, 'Log')
				LogToDrop.Parent = workspace
				LogToDrop.Position = treeLog.Position
			end
		end)
	end
end

Everytime I run this it gets paused for debugging and tells me it is on line 1. I’m new to Roblox development and to me there doesn’t seem to be anything wrong with this code at all and its weird cause it was all working at one point.
If anyone is able to help that would be much appreciated, thank you

Make sure you don’t have the debug markers within your script. These are red dots next to a line number. You can right click it to get the option to delete it.

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.