#for loop not looping through all parts?

1 messages · Page 1 of 1 (latest)

magic vortex
#
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local AuraStats = require(ReplicatedStorage.Modules.AuraStats)
local prompt = script.Parent
local bases = workspace.Map.Bases
local rig = prompt.Parent

local function stealAura(player: Player)
    local character = player.Character
    rig.HumanoidRootPart:FindFirstChild("Stolen").Enabled = true
    
    for i, v in rig:GetDescendants() do
        if (v:IsA("BasePart") or v:IsA("Decal")) then
            print("sigma")
            v.Transparency = 0.5
        end
    end
    
    local stolenAura = rig:Clone()
    
    local weld = Instance.new("Motor6D")
    weld.Part0 = character.PrimaryPart
    weld.Part1 = stolenAura.PrimaryPart
    weld.Parent = character.PrimaryPart
    stolenAura:FindFirstChild("ProximityPrompt"):Destroy()
    character:FindFirstChild("Humanoid").WalkSpeed = 12
    stolenAura.Parent = character
    for i, v in stolenAura:GetDescendants() do
        if v:IsA("BasePart") then
            v.CanCollide = false
            print(v.Name)
        end
    end
end

prompt.Triggered:Connect(function(player: Player)
    local owner = rig.Parent.Parent.Parent.Parent:FindFirstChild("Owner").Value
    
    if owner == player.Name then
        local money = player:FindFirstChild("leaderstats"):FindFirstChild("Money")
        local sellPrice = AuraStats[rig.Name].Price / 2
        money.Value += sellPrice
        rig.Parent.Parent.Value = ""
        rig:Destroy()
    else
        stealAura(player)
    end
end)
barren tangleBOT
#

studio** You are now Level 6! **studio

magic vortex
#

for some reason the v.CanCollide = true only applies to every part EXCEPt the torso and the head and i have no idea why

#

it has something to do with the rig having a humanoid

#

so i deleted the humanoid as a temporary fix

solemn haven
magic vortex
#

they are on a diff collision group

#

but they're connected to the rig via motor6d so they still affect physics

solemn haven
#

Humanoids are enabling collision itself

magic vortex
#

well there's not really a workaround bc they have to be conected

solemn haven
#

Im sure there's a way but idek, you wanna put it in the last cause it may be caused by the instances not being loaded yet