My very first post .I have problem with raycasting while using bodyvelocity .Raycasting starts fine at the start but then gets stretched at the last position … How do i fix this ? Since it’s a rotating while moving skill i guess raycasting need to work till animation stops ,otherwise you may not deal damage .I’m using RaycastingHitboxv4 module .
My very first post .I have problem with raycasting while using bodyvelocity .Raycasting starts fine at the start but then gets stretched at the last position … How do i fix this ? Since it’s a rotating while moving skill i guess raycasting need to work till animation stops ,otherwise you may not deal damage .I’m using RaycastingHitboxv4 module .
- Wrong category. Move to #help-and-feedback:scripting-support
- Nobody can help you without seeing your code.
- Stop typing spaces before punctuation symbols, it’s not correct. Type space AFTER punctuation.
Because such end of sentance
.Is not good.
local Tool = script.Parent
local Handle = Tool.Handle
local Anims = Tool.Anims
local RaycastHitbox = require(game.ServerScriptService.RaycastHitboxV4)
local Hitbox = RaycastHitbox.new(Tool.Hitbox)
local de = false
local canHit = false
local isSkillActive = false
local isDoubleStrikeActive = false
local hitList = {}
local currentAnimation
config = {
Damage = 5,
AttackTime = .55,
Cooldown = .25,
SkillDamage = 30,
SkillCooldown = 2,
SkillDuration = 0.5,
RaycastDistance = 45,
SkillMovementSpeed = 40,
SkillMovementDuration = 0.4,
DoubleStrikeDamage = 25,
DoubleStrikeCooldown = 3,
DoubleStrikeDuration = 0.7
}
local animationIndex = 1
Hitbox.OnHit:Connect(function(hit, humanoid)
if not canHit then return end
canHit = false
if humanoid == nil then
local character = hit:FindFirstAncestorOfClass("Model")
if character then
humanoid = character:FindFirstChildOfClass("Humanoid")
end
end
if humanoid and humanoid.Parent ~= script.Parent.Parent and not hitList[humanoid] then
hitList[humanoid] = true
local damage = isSkillActive and config.SkillDamage or (isDoubleStrikeActive and config.DoubleStrikeDamage or config.Damage)
humanoid:TakeDamage(damage)
local character = humanoid.Parent
local rootPart = character:FindFirstChild("HumanoidRootPart")
if rootPart then
local Knockback = Instance.new("BodyVelocity")
Knockback.P = math.huge
Knockback.Parent = rootPart
Knockback.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
Knockback.Velocity = rootPart.CFrame.lookVector * -7
game:GetService("Debris"):AddItem(Knockback, .3)
end
end
task.wait(0.01)
canHit = true
end)
script.Parent.Hit.OnServerEvent:Connect(function(Player)
if de == false then
de = true
hitList = {}
local Humanoid = Player.Character.Humanoid
local AnimationsList = Anims:GetChildren()
if currentAnimation then
currentAnimation:Stop()
currentAnimation = nil
end
if animationIndex > #AnimationsList then
animationIndex = 1
end
local Selected = Humanoid:LoadAnimation(AnimationsList[animationIndex])
currentAnimation = Selected
Selected:Play()
animationIndex = animationIndex + 1
delay(config.AttackTime, function()
if currentAnimation then
currentAnimation:Stop()
currentAnimation = nil
end
end)
Hitbox:HitStart()
canHit = true
wait(config.AttackTime)
Hitbox:HitStop()
canHit = false
wait(config.Cooldown)
de = false
end
end)
local skillCooldown = false
script.Parent.Skill.OnServerEvent:Connect(function(Player)
if not skillCooldown then
skillCooldown = true
hitList = {}
local Character = Player.Character
local Humanoid = Character.Humanoid
local RootPart = Character:FindFirstChild("HumanoidRootPart")
if currentAnimation then
currentAnimation:Stop()
currentAnimation = nil
end
local SkillAnim = Instance.new("Animation")
SkillAnim.AnimationId = "rbxassetid://84334177666926"
local SkillTrack = Humanoid:LoadAnimation(SkillAnim)
currentAnimation = SkillTrack
SkillTrack:Play()
delay(config.SkillDuration, function()
if currentAnimation then
currentAnimation:Stop()
currentAnimation = nil
end
end)
isSkillActive = true
canHit = true
if RootPart then
local ForwardDirection = RootPart.CFrame.LookVector
local MovementVelocity = ForwardDirection * config.SkillMovementSpeed
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Velocity = MovementVelocity
BodyVelocity.MaxForce = Vector3.new(math.huge, 0, math.huge)
BodyVelocity.Parent = RootPart
game:GetService("Debris"):AddItem(BodyVelocity, config.SkillMovementDuration)
end
Hitbox:HitStart(config.SkillDuration)
wait(config.SkillDuration)
Hitbox:HitStop()
isSkillActive = false
canHit = false
wait(config.SkillCooldown - config.SkillDuration)
skillCooldown = false
end
end)
local doubleStrikeCooldown = false
local doubleStrikeReady = true
local function resetDoubleStrike()
wait(config.DoubleStrikeCooldown)
doubleStrikeCooldown = false
doubleStrikeReady = true
print("Double Strike is ready again")
end
script.Parent.DoubleStrike.OnServerEvent:Connect(function(Player)
print("Double Strike event received")
print("doubleStrikeReady:", doubleStrikeReady)
print("doubleStrikeCooldown:", doubleStrikeCooldown)
if doubleStrikeReady and not doubleStrikeCooldown then
print("Double Strike activated")
doubleStrikeCooldown = true
doubleStrikeReady = false
hitList = {}
local Character = Player.Character
local Humanoid = Character.Humanoid
local RootPart = Character:FindFirstChild("HumanoidRootPart")
if currentAnimation then
print("Stopping current animation")
currentAnimation:Stop()
currentAnimation = nil
end
print("Loading Double Strike animation")
local DoubleStrikeAnim = Instance.new("Animation")
DoubleStrikeAnim.AnimationId = "rbxassetid://128566617410903"
local DoubleStrikeTrack = Humanoid:LoadAnimation(DoubleStrikeAnim)
currentAnimation = DoubleStrikeTrack
print("Playing Double Strike animation")
DoubleStrikeTrack:Play()
wait(0.1)
local animDuration = DoubleStrikeTrack.Length
print("Animation duration:", animDuration)
isDoubleStrikeActive = true
canHit = true
Hitbox:HitStart()
print("Waiting for animation to complete")
wait(animDuration)
Hitbox:HitStop()
isDoubleStrikeActive = false
canHit = false
if currentAnimation then
print("Stopping Double Strike animation")
currentAnimation:Stop()
currentAnimation = nil
end
spawn(resetDoubleStrike)
-- Notify the player that the skill is on cooldown
script.Parent.DoubleStrike:FireClient(Player, "cooldown", config.DoubleStrikeCooldown)
else
print("Double Strike not ready")
-- Notify the player that the skill is still on cooldown
if doubleStrikeCooldown then
script.Parent.DoubleStrike:FireClient(Player, "stillOnCooldown")
end
end
end)
script.Parent.Equipped:Connect(function()
doubleStrikeCooldown = false
doubleStrikeReady = true
print("Tool equipped, Double Strike is ready")
end)
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {Tool.Parent}
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
Hitbox.RaycastParams = raycastParams
Hitbox:Recalibrate()
It’s better to learn how to write posts from start than being surprised with punishment for 5-6 posts taken down for such things…
Anyways, as I said above, to hep you with your problem, we need to see your code. Function which uses problematic raycasting…
EDIT: use ``` before and after your code to format it correctly, like this:
This text will be formated like code.
Also you can use this button to make the same, but select all code before.
I think its got something to do with the handle. The animation seems to stop very fast at the end. Try making the animation fade out more longer?
I tried but no luck. I think, it’s module itself , because it creates rays from one point to another(LastPosition) and when i spin (during animation) it creates full circle of rays but i’m not sure module is scripted to account movement (bodyvelocity in my case), so it doesn’t keep up or update with movement.
So, made animation longer(X3) and swaped body velocity with just movement . Looks better but still not sure . It kinda stays behind on player. I read somewhere you can update rays in front of you. Can you ?? If anyone have done similar skill, share your thoughts please. I’m burned out for now.