i am using this module for my lightsabergame and now i want to add blocking!
(!BTW RAYCASTING IS PRETTY NEW FOR ME!)
i dont know what i need to do to make the blocking work but i want to make it so when a value in a tool is true blocking will be enabled and the raycasthitbox does no dmg to the player with the blocking value… here is the serversided code i used for the attacks
local remoteEvent = script.Parent.Parent.AttackFolder.Attack1
local tool = script.Parent.Parent
local plr = tool.Parent.Parent
local char = plr.Character
local m1 = script.Parent.Parent.Handle.Hit
local Damage = script.Parent.Parent.dmgfolder.dmg.Value
local RaycastHitbox = require(game.ServerScriptService.RaycastHitboxV4)
local Hitbox = RaycastHitbox.new(script.Parent.Parent["Lightsaber top"].Part)
hitted = false
blockhitted = false
remoteEvent.OnServerEvent:Connect(function()
Hitbox:HitStart()
local Attack = script.Parent.Parent.Parent.Humanoid:LoadAnimation(script.Parent.Parent.Anims.Attack1)
print("Server Attack1!")
Hitbox.OnHit:Connect(function(hit, humanoid)
if hitted then return end
hitted = true
if humanoid.Parent ~= char then
humanoid:TakeDamage(Damage)
m1:Play()
print(hit.Name)
humanoid:LoadAnimation(script.Parent.Parent.Anims.Hit) -- does not work i cant locate the humanoid i hit
end
hitted = false
end)
Attack:Play()
wait(0.3)
Hitbox:HitStop()
end)
wait(2)
m1:Stop()
and here is the blockedvalue i would like to get detected (In the tool)
thanks for helping i will try some solutions myself too.
For one of my games i have a script in serverscriptservice that adds the attribute “CanBlock” to your humanoid, this is what the code looks like
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:FindFirstChild("Humanoid")
if Humanoid ~= nil then
Humanoid:SetAttribute("Blocking", false)
Humanoid:SetAttribute("CanParry", false)
end
end)
end)
For a simple blocking mechanic you could check if blocking is true upon hitting the enemy, that would look something like:
local CheckBlock = enemyhumanoid:GetAttribute("Blocking")
if CheckBlock == true then
--code here depending on what you want to do when they hit a block
end
I’m having issues with this. I’m not sure if I am doing something wrong but if I stand still and hit the same character it stops detecting the hits unless I move prior to hitting it.
local handle = script.Parent
local tool = handle.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RaycastHitbox = require(ReplicatedStorage.RaycastHitboxV4)
local newHitbox = RaycastHitbox.new(script.Parent)
local Params = RaycastParams.new()
local hitSound = handle:WaitForChild("Hit")
local swingSound = handle:WaitForChild("Swing")
local charDefined = false
tool.Equipped:Connect(function()
if not charDefined then
charDefined = true
Params.FilterDescendantsInstances = {tool.Parent}
Params.FilterType = Enum.RaycastFilterType.Exclude
newHitbox.RaycastParams = Params
end
end)
local deboucne = false
local turnOffAfterThisAmountOfSeconds = .25
tool.Activated:Connect(function()
if deboucne == false then
deboucne = true
swingSound:Play()
newHitbox:HitStart(turnOffAfterThisAmountOfSeconds)
tool.Grip = CFrame.new(Vector3.new(0, 0, -1.25)) * CFrame.Angles(math.rad(180),0,0)
task.wait(0.75)
tool.Grip = CFrame.new(Vector3.new(0, 0, -1.25)) * CFrame.Angles(math.rad(90),0,0)
task.wait(.25)
deboucne = false
end
end)
newHitbox.OnHit:Connect(function(hit, humanoid)
hitSound:Play()
print(hit)
humanoid:TakeDamage(1)
end)
I believe the rays would require a non-zero direction vector. Not moving means the displacement is 0 and that means the direction vector’s magnitude is 0, meaning the direction vector is itself a zero vector.
FastCast is better suited for projectiles, but this one is for melee weapons as the title says “For all your melee needs!”, while FastCast on the other hand, it says this in the title “Making a combat game with ranged weapons?”
Off-Topic but I dont think the creator is gonna update this. I checked his profile and it says “Out of devforum due to life stuff.” But he’s probably gonna be active more, so who knows?
Anyways, I dont use this anymore. I’m currently using a “BoundingBox” method to do this. This module is limited. And yes, I still use “Blacklist” and “Whitelist”. I just get the new ones mixed up.
But this causes some lag now.
I hope someone remakes this module!
What happens if i just repeat HitStart() again without calling HitStop()?
It appears that it just restarts the hit detection but im unsure about what the backend looks like or if this causes a performance issue.