So I have a working block system for a jojo game. It works just fine however I wanted it to have it so when you hit the player from behind(since when the stand is blocking it is in front of the player) the hit will still connect and deal damage. I have tried using CFrame to detect it but failed miserably and I'm stuck. Any suggestions or even a possible solution?
Here is my server blocking script. I also have a local blocking script that basically is the way it detects if you are going to block.
local rp = game:GetService("ReplicatedStorage") local Block = rp:WaitForChild("Block") local TweenService = game:GetService("TweenService") local SSS = game:GetService("ServerScriptService") local Library = SSS:WaitForChild("Library") local DictionaryHandler = require(Library:WaitForChild("DictionaryHandler"))
Block.OnServerEvent:Connect(function(Player,isActive) local Character = Player.Character local Humanoid = Character.Humanoid local HumanoidRP = Character.HumanoidRootPart
if not DictionaryHandler.findPlayer(Humanoid,"Stunned")then
if isActive then
--if player is blocking
local Stand = Character:FindFirstChild("Stand")
if Stand then
local AnimController = Stand:FindFirstChild("AnimController")
if AnimController then
local Controller = Stand.PrimaryPart:FindFirstChild("Controller")
if Controller then
local goal = {}
goal.C0 = Controller.Part0.CFrame:ToObjectSpace(Controller.Part1.CFrame)
goal.C1 = Controller.Part0.CFrame:ToObjectSpace(Controller.Part1.CFrame * CFrame.new(0,0.25,-2))
local info = TweenInfo.new(0.25)
local Tween = TweenService:Create(Controller,info,goal)
Tween:Play()
local anim = AnimController:LoadAnimation(script:WaitForChild("Block"))
anim:Play()
Humanoid.WalkSpeed = 8
Humanoid.JumpPower = 0
DictionaryHandler.addTo(Humanoid,"Blocking")
end
end
else
Block:FireClient(Player)
end
else
--if player is not blocking
local Stand = Character:FindFirstChild("Stand")
if Stand then
local AnimController = Stand:FindFirstChild("AnimController")
if AnimController then
local Controller = Stand.PrimaryPart:FindFirstChild("Controller")
if Controller then
local goal = {}
goal.C0 = Controller.Part0.CFrame:ToObjectSpace(Controller.Part1.CFrame)
goal.C1 = Controller.Part0.CFrame:ToObjectSpace(Controller.Part1.CFrame * CFrame.new(-3,1,2))
local info = TweenInfo.new(0.25)
local Tween = TweenService:Create(Controller,info,goal)
Tween:Play()
for _, track in pairs(AnimController:GetPlayingAnimationTracks()) do
if track.Name == "Block" then
track:Stop()
end
end
Humanoid.WalkSpeed = 18
Humanoid.JumpPower = 50
DictionaryHandler.removeFrom(Humanoid,"Blocking")
end
end
else
Block:FireClient(Player)
end
end
end
end)
