hi i want some help i do block system and sword system the problem is block not work
but when npc do block it work but when i do they hit me
We need the script to help you.
Without providing any sources of scripts, we’re unable to help you.
1 Like
sure
--|| Services ||--
local Players = game:GetService("Players")
local Debris = game:GetService("Debris")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")
local TweenService = game:GetService("TweenService")
--|| Remotes ||--
local SwordClient = ReplicatedStorage.Remotes.SwordClient
local AnimationRemote = ReplicatedStorage.Remotes.AnimationRemote
local CameraRemote = ReplicatedStorage.Remotes.CameraRemote
--|| Asssets ||--
local Target = ReplicatedStorage.Assets.MiscMeshes["BP"]
--|| Modules ||--
local GlobalFunctions = require(ReplicatedStorage.GlobalFunctions)
local HitboxModule = require(ServerScriptService.SERVER.Greatsword.HitboxModule)
local DamageHandler = require(ServerScriptService.SERVER.Handlers.DamageHandler)
local HitboxData = {
StartPoint = Vector3.new(2.75,2.75,2.75);
EndPoint = Vector3.new(2.75,2.75,2.75)
}
local CameraData = {Size = 30; Length = .25}
local SwordCombat = {
["Feint"] = function(Character,TaskName,FunctionName,Data)
local Player = Players:GetPlayerFromCharacter(Character)
GlobalFunctions:AddValue("BoolValue", "Stun", false, Character,.25)
GlobalFunctions:AddValue("BoolValue", "Feint", false, Character,.35)
SwordClient:FireAllClients({Module = "SwordVFX", Function = "SwordFeint", Character = Character})
AnimationRemote:FireClient(Player,"sword","StopClass")
end;
["Block"] = function(Character,KeyName,ToolName,Data)
local Player = Players:GetPlayerFromCharacter(Character)
local Humanoid = Character:FindFirstChild("Humanoid")
if not GlobalFunctions:CheckValue(Player,"BlockCooldown") and not GlobalFunctions:CheckValue(Player,"%$@#^@#%$^@#") then
AnimationRemote:FireClient(Player,"swordblocko","Play")
local BlockHits = GlobalFunctions:AddValue("NumberValue", "BlockHits", 6, Character)
local BlockingUI = Character.UpperTorso:FindFirstChild("Blocking")
local Holder = BlockingUI:FindFirstChild("Holder")
local Bar = Holder:FindFirstChild("Bar")
local Text = Holder:FindFirstChild("Text")
local T2 = Holder:FindFirstChild("Shadow")
BlockingUI.Enabled = true
while GlobalFunctions:GetKeyHeld(Player,"MouseButton2","Mouse") and Character:FindFirstChild("BlockHits") do
if Character:FindFirstChild("BlockHits") then
GlobalFunctions:AddValue("BoolValue", "Stun", false, Character, .2)
Humanoid.WalkSpeed = 7;
Humanoid.JumpPower = 0;
TweenService:Create(Bar,TweenInfo.new(.2,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0),{Size = UDim2.new(Character.BlockHits.Value/6,0,1)}):Play()
Text.Text = Character.BlockHits.Value.."/"..6
T2.Text = Text.Text
wait(.1)
end
end
GlobalFunctions:SetCooldown(Player,"BlockCooldown",1)
BlockingUI.Enabled = false
Humanoid.WalkSpeed = 11;
Humanoid.JumpPower = 50;
BlockHits:Destroy()
AnimationRemote:FireClient(Player,"swordblocko","Stop")
end
end;
["Sword"] = function(Character,KeyName,ToolName,Data)
local Player = Players:GetPlayerFromCharacter(Character)
local Root = Character:FindFirstChild("HumanoidRootPart")
local Combo = Character:FindFirstChild("Combo")
local GreatswordWep = Character:FindFirstChild("GreatswordModel")
if Character:FindFirstChild("Stun") then return end
if not GlobalFunctions:CheckCooldown(Player,"SwordSwingCooldown") then
if Player.PlayerStats.KeysLogged.Value == 4 then
GlobalFunctions:ChangeValue(Player.PlayerStats, "Set", "KeysLogged", 0)
GlobalFunctions:AddValue("BoolValue", "Stun", false, Character, 1)
end
GlobalFunctions:SetCooldown(Player,"SwordSwingCooldown",.35)
GlobalFunctions:ChangeValue(Player.PlayerStats, "Once", "KeysLogged", 1)
AnimationRemote:FireClient(Player, "sword"..Player.PlayerStats.KeysLogged.Value, "Play")
GlobalFunctions:AddValue("BoolValue", "%$@#^@#%$^@#", false, Character, .75)
SwordClient:FireAllClients({Module = "SwordVFX", Function = "SwordSwing", Character = Character})
local hitResult,hitObject = HitboxModule.Region(Character,1,ToolName,HitboxData,ToolName,Player.PlayerStats:FindFirstChild("KeysLogged"))
if hitResult == true then
local Victim = hitObject.Parent
local VHumanoid = Victim:FindFirstChild("Humanoid")
local VRoot = Victim:FindFirstChild("HumanoidRootPart")
delay(.15,function()
local BG = Instance.new("BodyGyro"); BG.MaxTorque = Vector3.new(0,4e4,0); BG.P = BG.P * 10; BG.CFrame = CFrame.new(VRoot.Position,Root.Position) BG.Parent = VRoot
_G.Debris(BG,.5)
end)
if Combo and Combo.Value < 5 then
delay(.19,function()
if not Victim:FindFirstChild("BlockHits") and not Victim:FindFirstChild("Choosing") then
if not Character:FindFirstChild("Feint") then
SwordClient:FireAllClients({Module = "SwordVFX", Function = "SwordSlash", Character = Character, Victim = Victim})
local BodyVelocity = Instance.new("BodyVelocity"); BodyVelocity.Name = "LittleKnockback" BodyVelocity.MaxForce = Vector3.new(1e8,1e8,1e8); BodyVelocity.Velocity = (VRoot.CFrame.p - Root.CFrame.p).unit * 5; BodyVelocity.Parent = Victim:FindFirstChild("Head")
_G.Debris(BodyVelocity,.2)
end
end
end)
end
if Victim:FindFirstChild("BlockHits") then
local BlockHits = Victim:FindFirstChild("BlockHits")
BlockHits.Value = BlockHits.Value - 1
end
GlobalFunctions:AddValue("BoolValue", "Stun", false, Victim, .55)
if not Character:FindFirstChild("Feint") then
DamageHandler.TakeDamage(Character,VHumanoid,ToolName,5)
end
delay(.185,function()
if not Victim:FindFirstChild("BlockHits") and not Victim:FindFirstChild("Choosing") then
GlobalFunctions:AddSound(Root, "Slash"..Player.PlayerStats.KeysLogged.Value, 1.75, false)
VHumanoid:LoadAnimation(ReplicatedStorage.Animations.sword.HitReactions["HitReaction"..Combo.Value]):Play()
else
VHumanoid:LoadAnimation(ReplicatedStorage.Animations.sword.HitReactions.BlockHitReaction["bhitreaction"..math.random(1,2)]):Play()
end
end)
GlobalFunctions:ChangeValue(Character, "Once", "Combo", 1)
delay(.15,function()
GlobalFunctions:ChangeValue(Character,"Once","Hits",1 )
end)
coroutine.wrap(function()
if Combo.Value == 5 and not Victim:FindFirstChild("BlockHits") and not Victim:FindFirstChild("Choosing") then
VHumanoid:LoadAnimation(ReplicatedStorage.Animations.sword.HitReactions.HitReaction5):Play()
wait(.185)
SwordClient:FireAllClients({Module = "SwordVFX", Function = "SwordLastHit", Character = Character, Victim = Victim})
local EnemyVelocity = Instance.new("BodyVelocity"); EnemyVelocity.MaxForce = Vector3.new(1e5 ,1e5 ,1e5 ); EnemyVelocity.Velocity = (VRoot.CFrame.p - Root.CFrame.p).unit * 120; EnemyVelocity.Parent = Victim.Head
_G.Debris(EnemyVelocity,.2)
CameraRemote:FireClient(Player, "LightScreenShake")
GlobalFunctions:AddSound(Character.HumanoidRootPart, "KnockbackTing", 1.5, false)
CameraRemote:FireClient(Player,"CreateBlur",CameraData)
end
end)()
end
if Player.PlayerStats.KeysLogged.Value >= 1 then
spawn(function()
GlobalFunctions:AddSound(Root, "SwingSharp1", 1.75, false)
local ygm = Target:Clone(); ygm.CFrame = Root.CFrame * CFrame.new(0,0,-5); local bp = Instance.new("BodyPosition",Root); bp.Name = "Knockback"; bp.MaxForce = Vector3.new(1,1,1)* 800000; bp.D = 1800; bp.Position = ygm.Position; Debris:AddItem(bp,.2); Debris:AddItem(ygm,.2)
end)
end
end
end;
["Equipped"] = function(Character,KeyName,WeaponName,Data)
local WeaponSword = ReplicatedStorage.Weapons:FindFirstChild("GreatswordModel")
WeaponSword = WeaponSword:Clone()
WeaponSword.Name = "GreatswordModel"
WeaponSword.Parent = Character
GlobalFunctions:AddSound(Character:FindFirstChild("HumanoidRootPart"), "UnSheath")
local RightHand = Character:FindFirstChild("RightLowerArm")
local Motor6D = Instance.new("Motor6D")
Motor6D.Part0 = Character:FindFirstChild("RightHand")
Motor6D.Part1 = WeaponSword:FindFirstChild("MainPrimaryPart")
Motor6D.Parent = WeaponSword
end;
["UnEquipped"] = function(Character,KeyName,WeaponName,Data)
for _,v in pairs(Character:GetChildren()) do
if v.Name == "GreatswordModel" then
v:Destroy()
end
end
end;
}
return SwordCombat
1 Like
--|| Services ||--
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Debris = game:GetService("Debris")
local ServerStorage = game:GetService("ServerStorage")
--|| Variables ||--
local RemoteFolder = ReplicatedStorage.Remotes
--|| Remotes ||--
local ClientRemote = RemoteFolder.SwordClient
local CameraRemote = RemoteFolder.CameraRemote
local AnimationRemote = RemoteFolder.AnimationRemote
--|| Modules ||--
local GlobalFunctions = require(ReplicatedStorage.GlobalFunctions)
local Ragdoll = require(ServerStorage.Modules.Ragdoll)
local BlurData = {Size = 30; Length = .25}
local DamageHandler = {
TakeDamage = function(Character,Inflicted,ToolName,Damage)
local Player = Players:GetPlayerFromCharacter(Character)
local Humanoid = Character:FindFirstChild("Humanoid")
if Inflicted.Health > 0 and Humanoid.Health > 0 then
local EnemyCharacter = Inflicted.Parent
local EnemyPlayer = Players:GetPlayerFromCharacter(EnemyCharacter)
local State = EnemyCharacter:FindFirstChild("BlockHits")
local Feint = EnemyCharacter:FindFirstChild("Feint")
if Feint then
if Player then
AnimationRemote:FireClient(Player,nil,"StopAllAnimations")
AnimationRemote:FireClient(Player,"swordazed","Play")
delay(1.25,function()
AnimationRemote:FireClient(Player,"swordazed","Stop")
end)
GlobalFunctions:AddValue("BoolValue", "Stun", false, Character, 1.5)
end
end
if State then
local BlockHits = EnemyCharacter:FindFirstChild("BlockHits")
if BlockHits.Value >= 1 then
delay(.175,function() GlobalFunctions:DamageIndicator(EnemyCharacter,"-"..Damage/3); ClientRemote:FireAllClients{Module = "SwordVFX"; Function = "Block"; Victim = EnemyCharacter} end)
Inflicted.Health = Inflicted.Health - Damage/3
end
if BlockHits.Value <= 0 then
if EnemyPlayer then
AnimationRemote:FireClient(EnemyPlayer,"swordazed","Play")
delay(1.25,function()
AnimationRemote:FireClient(EnemyPlayer,"swordazed","Stop")
end)
else
local AnimTing = Inflicted:LoadAnimation(ReplicatedStorage.Animations.sword.swordazed)
AnimTing:Play()
delay(1.25,function()
AnimTing:Stop()
end)
end
GlobalFunctions:AddValue("BoolValue", "Choosimg", false, EnemyCharacter, .7)
GlobalFunctions:AddValue("BoolValue", "Stun", false, EnemyCharacter, 1.5)
BlockHits:Destroy()
GlobalFunctions:AddValue("BoolValue", "Stun", false, EnemyCharacter, 1.5)
EnemyCharacter.HumanoidRootPart.Anchored = true
coroutine.resume(coroutine.create(function()
wait(1.5)
EnemyCharacter.HumanoidRootPart.Anchored = false
end))
delay(.175,function() ClientRemote:FireAllClients{Character = Character; Module = "SwordVFX"; Function = "GuardBreak"; Victim = EnemyCharacter} end)
end
else
if EnemyCharacter:FindFirstChild("Choosing") == nil and EnemyCharacter:FindFirstChild("Feint") == nil then
delay(.175,function() Inflicted.Health = Inflicted.Health - Damage; GlobalFunctions:DamageIndicator(EnemyCharacter,"-"..Damage) end)
end
end
end
end;
}
return DamageHandler
1 Like
did you know how fix it or no 
What console message saying?
Maybe ServerScriptService turned into nothing.
it all work but i need script to do hit for block hit for play block