Why Isn't This Script Doing Damage

local plr = game.Players.LocalPlayer

script.Parent.Handle.Touched:Connect(function(touch)

if script.Parent.CanDamage.Value == true then
	
	if not touch.Parent:FindFirstChild("Humanoid") then return end
	
	script.Parent.CanDamage.Value = false
	
	touch.Parent.Humanoid:TakeDamage(plr.leaderstats.Power.Value)
	
	if touch.Parent.Humanoid.Health < 1 then
		
		local plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
		plr.leaderstats.Kills.Value = plr.leaderstats.Kills.Value + 1
	
	end
	
	wait(1)
	
	script.Parent.CanDamage.Value = true
	
end

end)

I think it’s because you’re running the Code via a LocalScript and not via Server?

im using a normal script i dont know why it is not working

That’s because you can’t get the LocalPlayer via a Server Script.

Then why did you suggested to change between client to server?
image

Anyway, are you sure that the CanDamage value is actually true @Fallguysgod1234567? Also a debouncer can be done with a single variable as the control variable.

local debouncer = false

local function onHit()
    if debouncer then return end
    debouncer = true

    task.wait(1)
    debouncer = false
end

how do u do a local plr = game.Players.LocalPlayer in a script please tell me

You can’t, you can access the Player via Remotes, or in the PlayerAdded event. The LocalPlayer is just for the current client (yourself).

replace the plr variable with
local plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)

You don’t know if the script is under the character, this won’t work if it’s not like that.

If he’s using
local plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
then probably he knows.

If he was already using this method, why did you answer with the same problematic? This doesn’t make any sense, refrain from answering with the same code that is being used.

This will replace the LocalPlayer, which you cant get from server side

So
local plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
Is the player who’s holding the tool.

He has already implemented that.

image

Not sure why you’re keeping with this.

local plr = game.Players.LocalPlayer

touch.Parent.Humanoid:TakeDamage(plr.leaderstats.Power.Value)