#the damage is not damaging the enemy

11 messages · Page 1 of 1 (latest)

half plaza
#

Soo.. I got a bug where the hitbox was not damaging the enemy even if the enemy model name isn't matched to the player's name to prevent the player getting damaged and damaging the enemy instead.

#

here's the script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local VFX = ReplicatedStorage.VFX

local VFXEvent = ReplicatedStorage.VFXEvent
local RTG = VFX.RTG

local MuchachoHitbox = require(ReplicatedStorage.MuchachoHitbox)

local function TakeDamage(humanoid, owner, damage)
    local character = humanoid.Parent
    if character and character:FindFirstChild("Humanoid") and character.Name ~= owner then
        humanoid:TakeDamage(damage)
    end
end

local function createHitbox(part, lifetime, owner)
    local randomYPosition = math.random(-5, 5)
    local randomZPosition = math.random(-6, -3)

    local hitbox = MuchachoHitbox.CreateHitbox()
    hitbox.Size = Vector3.new(3,3,5)
    hitbox.CFrame = part.CFrame * CFrame.new(math.random(-5, 2),math.random(-5, 2),math.random(-5, 2))
    
    hitbox.Touched:Connect(function(hit, hum)
        TakeDamage(hum, owner, 10)
    end)
    
    hitbox:Start()
    task.wait(lifetime)
    hitbox:Stop()
end

VFXEvent.OnServerEvent:Connect(function(player, value)
    local character = player.Character
    local humanoidrootpart, humanoid = character:WaitForChild("HumanoidRootPart"), character:WaitForChild("Humanoid")
    
    local wepon = RTG.Wepon:Clone()
    wepon.Parent = workspace
    wepon.CFrame = humanoidrootpart.CFrame * CFrame.new(0,0,-3)
    wepon.CanCollide = false
    
    humanoidrootpart.Anchored = true
    
    game.Debris:AddItem(wepon, 3)

    for i = 1, 50 do 
        createHitbox(wepon, 0.095, character.Name)
        createHitbox(wepon, 0.095, character.Name)
        createHitbox(wepon, 0.095, character.Name)
    end
    
    humanoidrootpart.Anchored = false
end)

small parcelBOT
#

studio** You are now Level 8! **studio

lavish ginkgo
#

Put a print statement in the damage function

#

Also add another rig, just a plain block one this time

#

@half plaza

half plaza
lavish ginkgo
#

what

#

all of it>

#

?