Scripting help with print

The Script in a part:
game:GetService(“ReplicatedStorage”):WaitForChild(“PlayerEvent”).OnServerEvent:Connect(function(plr)
while wait(1) do
local DistanceFromPart = (script.Parent.Position - plr.Character:WaitForChild(“HumanoidRootPart”).Position).magnitude
local TreeHealthGui = game.ReplicatedStorage.GuiTree.TreeHealth:Clone()
local ReplStorage = game:GetService(“ReplicatedStorage”)
local AxeAttackEvent = ReplStorage:WaitForChild(“RemoteEvents”):WaitForChild(“AxeAttack”)
if 15 > DistanceFromPart then

		if not script.Parent:FindFirstChild("TreeHealth") then
			TreeHealthGui.Parent = script.Parent
		end
		
		AxeAttackEvent.OnServerEvent:Connect(function(plr,axedamage)
                        print(axedamage)				
		end)
		
	elseif 15 < DistanceFromPart then	
		if script.Parent:FindFirstChild("TreeHealth") then
			script.Parent.TreeHealth:Destroy()
		end
end	

end
end)

the local script in a tool:

local Players = game:GetService(“Players”)

local localplayer = Players.LocalPlayer
local mouse = localplayer:GetMouse()

mouse.Button1Down:Connect(function(plr)

local AxeStats = script.Parent.AxeStatus
local RepltStorage = game:GetService("ReplicatedStorage")
local AxeAttackEvent = RepltStorage:WaitForChild("RemoteEvents"):WaitForChild("AxeAttack")
AxeAttackEvent:FireServer(AxeStats.AxeDamage.Value)
wait(1)

end)

and my problem is in the script.

		AxeAttackEvent.OnServerEvent:Connect(function(plr,axedamage)
                        print(axedamage)				
		end)

gives 10 prints per click. i want to do when i click give 1 print.

you must make a variable for the “AxeStats.AxeDamage.Value” ig

1 Like

still doesn’t working this script give like 5-10 prints

ok bud can you write the whole script just like

print("stuff here")

try adding a debounce

local db = true
AxeAttackEvent.OnServerEvent:Connect(function(plr,axedamage)
	if db then
		db = false
		print(axedamage)
		wait(0.5)
		db = true
	end
end)