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

This Damaing Module Wont work the player never takes damage?

Asked by
hokyboy 270 Moderation Voter
3 years ago
local DamageModule = {}

function DamageModule.DoDamage(Player,HitBoxSize,HitBoxShape,HitBoxCFrame,Damage)
    local NewHitbox = Instance.new("Part")
    NewHitbox.Size = HitBoxSize
    NewHitbox.Shape = HitBoxShape
    NewHitbox.CFrame = HitBoxCFrame
    NewHitbox.CanCollide = false
    NewHitbox.Transparency = 0
    NewHitbox.Anchored = true
    NewHitbox.Parent = workspace.HitBoxes

    local DamgedFolder = Instance.new("Folder")
    DamgedFolder.Parent = NewHitbox
    DamgedFolder.Name = "DamgedFolder"

    NewHitbox.Touched:Connect(function(HitObject)
        warn(HitObject.Parent.Name)
        if HitObject.Parent.Name == Player.Name then
            --print("Player Hit Themselfs")
        else
            --print("Something else hit the part determine if this has a humanoid")
            if HitObject.Parent:FindFirstChild("Humanoid") then
                --print("Part Does Have a humanoid Now time to check if this player or dummy has been hit before")
                if DamgedFolder:FindFirstChild(HitObject.Parent.Name) then
                    --print("Player was already damged")
                else
                    HitObject.Parent.Humanoid:TakeDamage(Damage)
                    local NewHT = Instance.new("ObjectValue")
                    NewHT.Name = HitObject.Parent.Name
                    NewHT.Parent = DamgedFolder
                    warn("Damged ".. HitObject.Parent.Name)
                    HitObject.Parent.Humanoid:TakeDamage(Damage)
                end 
            else
                -- Part Had No Humanoid
            end
        end
    end)
end

return DamageModule

I tested it with 2 players the only print i got is player was already damaged it never warned me of the other player getting damage why is this?

Answer this question