Trying to fix these fists, getting an arguement 1 missing or nil error?

I have these fists tools that were working fine, but now arn’t and from the looks of things, should work, but don’t, this is the local script inside the tool. There is also a server script inside that local, any help? Heres the localscript.

local tool= script.Parent
local plr= game.Players.LocalPlayer
repeat wait() until plr.Character

local char= plr.Character
local hum= char:WaitForChild("Humanoid")
local anim1= hum:LoadAnimation(script.Punch1)
local anim2= hum:LoadAnimation(script.Punch2)
local pE = script.punched

local on= false
local deb= false
local b1d
local mouse= plr:GetMouse()
local cooldown= .8

local rh= char:WaitForChild("RightHand")
local lh= char:WaitForChild("LeftHand")
local rht
local lht
local ud= game.ReplicatedStorage.updateStrength
local idle= hum:LoadAnimation(script.Idle)
local dmg
local durab

local throw= Instance.new("Sound",plr.Character.LowerTorso)
throw.SoundId="rbxassetid://711753382"

ud.OnClientEvent:Connect(function(p, dur, str, jelly, jaguar)
	dmg= dur
	durab= p
end)

tool.Equipped:Connect(function()
	if hum.Health <= 0 then return end
	idle:Play()
	b1d= mouse.Button1Down:Connect(function()
		if hum.Health <= 0 then return end
		if deb == false then deb= true
		if on == false then on = true
			anim1:Play()
			throw.Pitch= math.random(1,2)
			throw:Play()
			local mydeb= false
			rht= rh.Touched:Connect(function(hit)
				if hum.Health <= 0 then return end
				if mydeb == false then mydeb=true
				if hit.Parent:FindFirstChild("Humanoid") then
					pE:InvokeServer(hit.Parent.Humanoid,dmg, hit)
				end
				if hit.Parent.Parent:FindFirstChild("Humanoid") then
					pE:InvokeServer(hit.Parent.Parent.Humanoid,dmg,hit)
				end
				end
			end)
		elseif on == true then on = false
			anim2:Play()
			throw.Pitch= math.random(1,2)
			throw:Play()
			local mydeb= false
			lht= lh.Touched:Connect(function(hit)
				if hum.Health <= 0 then return end
				if mydeb == false then mydeb=true
				if hit.Parent:FindFirstChild("Humanoid") then
					pE:InvokeServer(hit.Parent.Humanoid,dmg,hit)
				end
				if hit.Parent.Parent:FindFirstChild("Humanoid") then
					local hum= hit.Parent.Parent:FindFirstChild("Humanoid")
					pE:InvokeServer(hum,dmg, hit)
				end
				end
			end)		
		end
		wait(cooldown)
		if lht then lht:disconnect() end
		if rht then rht:disconnect() end
		anim1:Stop()
		anim2:Stop()
		deb=false
		end
	end)
end)

tool.Unequipped:Connect(function()
	b1d:disconnect()
	if rht then rht:disconnect() end
	if lht then lht:disconnect() end
	idle:Stop()
end)

heres the server

local func= script.Parent.punched

func.OnServerInvoke = function(plr, hum, dmg, tor)

local sound= Instance.new("Sound")

sound.SoundId= "rbxassetid://137579113"

game.Debris:AddItem(sound,5)

sound.Parent=tor

sound:Play()

hum:TakeDamage(dmg)

end
1 Like

The issue most likely lies here. You only set the dmg variable in your OnClientEvent handler, yet your server script never fires any RemoteEvent, therefor the dmg is always nil.

(also next time, please include where the error is)

1 Like

Im confused on where I would put this?

You should send your output so we can have an idea of what the error is, but I think that what Kiriot said is true, your script never sends the damage to the client in the first place, so it always is nil.
Just noticed that “tor” is also not defined on the server.

To fix that you should :FireClient with the damage, or set the damage on the script to a default value and then when the server fires the client it will just change the default value to that. Also, why are you sending the damage to the client and sending it back to the server? You should handle most of your verifications on the serverscript and the sounds on the localscript, you never know when an exploiter decides to spam your remotes to create a bunch of sounds and potentially crash the server.