--local script
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local input = game:GetService("UserInputService")
local remote = game.ReplicatedStorage.swordd
local mouse = plr:GetMouse()
local db = true

if char:WaitForChild("Tool") then
input.InputBegan:Connect(function(key, gameprocced)
	if key.KeyCode == Enum.KeyCode.F and not gameprocced then
		local anim = Instance.new("Animation")
	anim.AnimationId = "http://www.roblox.com/Asset?ID=2628658141"
	local animtrack = game.workspace[plr.Name].Humanoid:LoadAnimation(anim)
	animtrack:Play()
		remote:FireServer(db)
		wait(3)
		db = false
	end
end)
end
--server script
local remote = game.ReplicatedStorage.swordd
remote.OnServerEvent:Connect(function(plr, pos,db)
	local char = plr.Character or plr.CharacterAdded:Wait()
	local sword = char:WaitForChild("Tool").Handle
	local dmg = false
	db = true
	
	sword.Touched:Connect(function(hit)
			local hum = hit.Parent:FindFirstChild("Humanoid")
			if hit.Parent:FindFirstChild("Humanoid") == nil then return end
			if dmg == false then
				dmg = true
				if hum.Parent == char then
	
		        hum.Health = hum.Health - 0
				else 
					hum.Health = hum.Health -  (plr.Backpack.SwordDmg.Value)
			end
		end
	end)
	wait(3)
	db = false
end)

the animation wont work on my right arm

2 comments

0

This is because from your tool, disable the tool holding animation so.

0

I just learned how to use RemoteEvents by reading your script, thanks lol.