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.