#I don't care about optimisation how do I make this not hit the player

1 messages · Page 1 of 1 (latest)

long isle
#
local Tool = script.Parent
local Handle = Tool.Handle
local db = true

Tool.Activated:Connect(function()
    local Hitbox = Instance.new("Part")
    Hitbox.Parent = workspace
    Hitbox.Position = Handle.Position
    Hitbox.Orientation = Handle.Orientation
    Hitbox.Size = Vector3.new(4, 4, 4)
    Hitbox.Transparency = 0.5
    Hitbox.Anchored = true
    Hitbox.CanCollide = false
    Hitbox.Touched:Connect(function(Hit)
        if db and Hit.Parent:WaitForChild("Humanoid") then
            db = false
            Hit.Parent.Humanoid:TakeDamage(10)
            Hitbox:Destroy()
            task.wait(0.5)
            db = true
        end
    task.wait(0.1)
    Hitbox:Destroy()
    end)
end)```
crystal lodge
#

just check if the hit isn't apart of the player using the tool

long isle
crystal lodge
#

just add "not playervariablehere.Character:FindFirstChild(hit)" to your if statement

long isle
crystal lodge
coarse gale
#

Is it better to do getpartsinsidepart instead of .touched for hitboxes?

little pollen
#

just add a lil

local players = game:GetService("Players")

if Hit.Parent = Players.LocalPlayer then
return
end