What this is doing is making the ray:
Origin: currentPosition
Direction: currentPosition - lastPosition
Endpoint: currentPosition + (currentPosition - lastPosition)
This makes the ray inaccurately go into things it hasn’t reached yet, or even into things it will never reach, the desired outcome should be going from current to last
Which would be:
Origin: currentPosition
Direction: lastPosition - currentPosition
Endpoint: lastPosition
Even with the corrected math, in my opinion going from current to last is unexpected behavior as I would assume the rays to travel in the direction of movement, last to current.
Which would be
Origin: lastPosition
Direction: currentPosition - lastPosition
Endpoint: currentPosition
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!