#in a grab attack i want to turn off the collide of the user that is being grabbed but its not workin

31 messages · Page 1 of 1 (latest)

upbeat sable
#
-- Function to create a hitbox and attempt to weld characters
local function createHitbox(player, position)
    local hitbox = Instance.new("Part")
    hitbox.Size = Vector3.new(10, 10, 10)
    hitbox.Anchored = true
    hitbox.CanCollide = false
    hitbox.Transparency = 0.9
    hitbox.CFrame = position
    hitbox.Parent = workspace

    local region = Region3.new(hitbox.Position - hitbox.Size / 2, hitbox.Position + hitbox.Size / 2)
    local weldCreated = nil  -- Variable to store the created weld

    -- Check for entities immediately
    local partsInRegion = workspace:FindPartsInRegion3(region, nil, math.huge)
    for _, part in pairs(partsInRegion) do
        if part and part.Parent then
            local humanoid = part.Parent:FindFirstChild("Humanoid")
            if humanoid and humanoid.Parent then
                local character = humanoid.Parent
                if character:IsA("Model") and character ~= player.Character then
                    humanoid.Health = humanoid.Health - 2
                    local victimAnimation = humanoid:LoadAnimation(VictimAnimation)
                    victimAnimation:Play()  -- Play victim animation

                    local victimRootPart = character:FindFirstChild("HumanoidRootPart")
                    local attackerRightArm = player.Character:FindFirstChild("Right Arm")
                    if victimRootPart and attackerRightArm then
                        weldCreated = weldVictimToArm(victimRootPart, attackerRightArm)
                    end
                end
            end
        end
    end

    -- Play success animation if welding was successful
    if weldCreated then
        local attackerHumanoid = player.Character:FindFirstChild("Humanoid")
        if attackerHumanoid then
            local successAnimation = attackerHumanoid:LoadAnimation(SuccessAnimation)
            successAnimation:Play()  -- Play success animation
        end
    end

    -- Clean up the hitbox
    hitbox:Destroy()

    return weldCreated  -- Return the weld if created
end

-- Function to periodically check and destroy expired welds
local function checkAndDestroyExpiredWelds()
    local currentTime = os.time()
    local removalIndices = {}

    -- Iterate through the activeWelds table to find expired welds
    for i, data in ipairs(activeWelds) do
        local elapsedTime = currentTime - data.timestamp
        if elapsedTime >= 2 then
            releaseWeldedCharacter(data.weld, nil)  -- Pass nil for character as we don't have the player object here
            table.insert(removalIndices, i)
        end
    end

    -- Remove the expired welds from the activeWelds table
    for i = #removalIndices, 1, -1 do
        table.remove(activeWelds, removalIndices[i])
    end
end

-- Modify the event connection to include release functionality
GrabEvent.OnServerEvent:Connect(function(player, position)
    if player then
        wait(0.5)
        local weld = createHitbox(player, position)

        if weld then
            -- The weld will be destroyed automatically by the checkAndDestroyExpiredWelds function
        else
            print("No weld was created")
        end
    end
end)

-- Periodically check and destroy expired welds (e.g., every second)
while true do
    checkAndDestroyExpiredWelds()
    wait(1)
end```
little obsidian
#

GO FUCK URSELF

#

IM NOT READING ALL THAT SHIT

#

FIND WHERE THE SCRIPT ISSUE IS FIRST

#

DUMBASS

upbeat sable
#

@little obsidian r u stupid or what? If you actually read before typing. I said it was a colliding issue.

#

I already added code to remove collide

#

its not working

#

so look around

#

find it

#

its legit the first 3 functions

little obsidian
#

then why did u send so much shit

upbeat sable
#

cus idk if its something that is bugging it

#

the colliding should work

#

the code for the collide is being executed

#

but its still not working

little obsidian
#

whats wrong with the character

upbeat sable
#

the user that is being grabbed

#

let me take a video

#

here you go

little obsidian
#

turn on PlatformStand on the victim's humanoid

#

if that doesnt work

#

then i think its an issue with the anim

upbeat sable
#

euhm the thing is that lets say i create a large hitbox well where ever the victim is located is where he will be grabbed.

#

i think thats the issue

#

he isnt being brought to the right place...

little obsidian
#

you can change his cframe to the correct one before welding him