Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = script.Parent.Parent.Parent;
- local character = player.Character;
- local t = character:WaitForChild("Torso");
- local tool = script.Parent;
- local handle = tool:WaitForChild("Handle");
- local isBlocking = tool:WaitForChild("IsBlocking");
- local remoteSword = tool:WaitForChild("RemoteSword");
- local swinging = false;
- local clashId = 135436314;
- local slashdmg = 40;
- remoteSword.OnServerEvent:connect(function(player, event)
- if event == 1 then
- isBlocking.Value = true;
- elseif event == 2 then
- isBlocking.Value = false;
- elseif event == 3 then
- swinging = true;
- wait(.4);
- swinging = false;
- end;
- end)
- handle.Touched:connect(function(hit)
- if swinging then
- if hit.Parent:FindFirstChild("Humanoid") then
- local h = hit.Parent:FindFirstChild("Humanoid");
- for i,v in pairs(h.Parent:GetChildren()) do
- if v:IsA("Tool") and v:FindFirstChild("IsBlocking") then
- local enemyWeapon = v
- if v then
- if enemyWeapon:FindFirstChild("IsBlocking").Value == true then
- if ((enemyWeapon.Handle.Position - t.Position).magnitude) < ((h.Parent.Torso.Position - t.Position).magnitude) then
- swinging = false;
- local clashSound = Instance.new("Sound", handle) or handle:FindFirstChild("Sound");
- clashSound.SoundId = "rbxassetid://"..clashId;
- clashSound:Play();
- elseif ((enemyWeapon.Handle.Position - t.Position).magnitude) > ((h.Parent.Torso.Position - t.Position).magnitude) then
- swinging = false;
- h:TakeDamage(slashdmg);
- end;
- elseif v:FindFirstChild("IsBlocking").Value == false then
- swinging = false;
- h:TakeDamage(slashdmg);
- end;
- else
- swinging = false;
- h:TakeDamage(slashdmg);
- end;
- end;
- end;
- end;
- end;
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement