Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is my raycasting sword script not working? or does more damage than planned

Asked by 2 years ago

I got this script from a youtuber but when I use it it either does more damage than it should or it doesn't work, I tried to use debounce but that makes it stop working, and if it does work it simply does more damage than planned

the scriot :

local ClientCast = require(game.ServerStorage.ClientCast)


local db = false

for i = -1.2,2,.1 do
    local Atachment = Instance.new("Attachment",script.Parent.Handle)
    Atachment.Name = "DmgPoint"
    Atachment.Position = Vector3.new(0,i,0)
end


local CasterParams = RaycastParams.new()

local slash

CasterParams.FilterDescendantsInstances = {script.Parent.Parent.Parent.Character or script.Parent.Parent.Parent.Parent.Character, script.Parent.Handle}
CasterParams.FilterType = Enum.RaycastFilterType.Blacklist


local slashcaster = ClientCast.new(script.Parent.Handle, CasterParams)

slashcaster.HumanoidCollided:Connect(function(result,hithumanoid)   
    if not db then
        db = true
        hithumanoid:TakeDamage(50)
        print("hit")
        wait(2)
        db = false
    end
end)

script.Parent.Equipped:Connect(function()
    local humanoid = script.Parent.Parent:FindFirstChild("Humanoid")
    if not slash then slash = humanoid:LoadAnimation(script.Animation); slash.Priority = Enum.AnimationPriority.Action end
end)


script.Parent.Activated:Connect(function()
    if not db then
        db = true
        slash:Play()
        slashcaster:Start()
        wait(2)
        slashcaster:Stop()
        db = false
    end
end)


script.Parent.Unequipped:Connect(function()
    if slash then slash:Stop() end
    slashcaster:Stop()
end)

I would appreciate a little help please I am new at this

Answer this question