Hi. I hopped into a game with a friend to test it out and I realized that I cannot see the damage that other players do to the enemy NPCs. I'm not quite sure what could be causing this. How can I fix this? Here's the damage script. Thanks!
local tool = script.Parent
local debounce = false
local swingsound = tool:WaitForChild("Swing")
local canattack = tool:WaitForChild("CanAttack")
local UIS = game:GetService('UserInputService')
local plr = game.Players.LocalPlayer
repeat wait() until plr.Character ~= nil
local char
local hum
local idle
local root = plr.Character:WaitForChild("HumanoidRootPart")
local debounce = false
local basiccombatdamage = 10
local function damagemarker()
local bill = Instance.new("BillboardGui")
bill.Parent = game.Workspace
bill.Active = false
bill.Adornee = char.Head
bill.AlwaysOnTop = false
bill.Enabled = true
bill.Size = UDim2.new(1.2, 0, 1.2, 0)
bill.StudsOffset = Vector3.new(math.random(-3, 3),math.random(-3, 3), math.random(-3, 3))
local text = Instance.new("TextLabel", bill)
text.BackgroundTransparency = 1
text.Name = "TakeDamage"
text.Size = UDim2.new(1.2, 0, 1.2, 0)
text.Font = "Fantasy"
text.FontSize = "Size48"
text.Text = "10"
text.TextColor3 = Color3.new(245, 255, 245)
text.TextScaled = true
text.TextStrokeColor3 = Color3.new(245, 245, 235)
text.TextStrokeTransparency = 0
text.TextWrapped = true
for i = 1, 25 do
wait(0.01)
text.Position = text.Position - UDim2.new(0, 0, 0.04, 0)
text.TextTransparency = text.TextTransparency + 0.04
text.TextStrokeTransparency = text.TextStrokeTransparency + 0.04
end
end
tool.Equipped:connect(function()
char = char or plr.Character or plr.CharacterAdded:wait()
hum = hum or char:WaitForChild("Humanoid")
idle = idle or hum:LoadAnimation(script.Idle)
idle:Play()
idle.Looped = true
end)
tool.Activated:connect(function()
if debounce == false then -- check if debounce is false
local ray = Ray.new(root.CFrame.p, root.CFrame.lookVector * 4)
local hit, hitposition = workspace:FindPartOnRay(ray, char)
canattack.Value = true
local swing1animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch1)
local swing2animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch2)
local choose = math.random(1,2)
if hit then
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if not humanoid then
humanoid = hit.Parent:FindFirstChild("Humanoid")
end
if humanoid ~= nil and (root.Position - hitposition).magnitude <= 50 then
local animspeed = swing1animation:AdjustSpeed(1000)
swing2animation:AdjustSpeed(1000)
print(animspeed)
print()
if choose == 1 then
debounce = true -- set debounce as true
swingsound:Play()
swing1animation:Play()
wait(.1)
humanoid:TakeDamage(basiccombatdamage)
damagemarker()
swingsound:Stop()
swing1animation:Stop()
debounce = false -- set debounce as false so the code can run again
elseif choose == 2 then
debounce = true -- set debounce as true
swingsound:Play()
swing2animation:Play()
wait(.1)
humanoid:TakeDamage(basiccombatdamage)
damagemarker()
swingsound:Stop()
swing2animation:Stop()
debounce = false -- set debounce as false so the code can run again
end
end
else
if choose == 1 then
debounce = true -- set debounce as true
local swing1animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch1)
swingsound:Play()
swing1animation:Play()
wait(.6)
swingsound:Stop()
swing1animation:Stop()
debounce = false -- set debounce as false so the code can run again
elseif choose == 2 then
debounce = true -- set debounce as true
local swing2animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch2)
swingsound:Play()
swing2animation:Play()
wait(.6)
swingsound:Stop()
swing2animation:Stop()
debounce = false -- set debounce as false so the code can run again
end
end
end
end)
tool.Deactivated:connect(function()
canattack.Value = true
end)
tool.Unequipped:connect(function()
idle:Stop()
end)

2 comments
Is this in a LocalScript or a server Scripts?
localscript, it's a punch tool