#Script is not detecting unanchored parts

1 messages · Page 1 of 1 (latest)

wise rune
#

Like this should work, right? It finds any parts that are already anchored, prints them out, and then anchors parts that weren't already. But it doesn't even detect any parts that aren't anchored, it doesn't even print out their names!

--Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")

--Consts/Vars
local tool = script.Parent
local onCooldown = false
local maxTime = 15
local cooldownTime = tool:WaitForChild("CooldownTime")

local part = ReplicatedStorage.Inverted_Sphere

--Tweens
local sizingTweenInfo = TweenInfo.new(
    1, --Time
    Enum.EasingStyle.Circular, --Easing Style
    Enum.EasingDirection.In, --Easing Direction
    0, --Repeat Count
    false, --Will reverse?
    0 --Delay
)

local reflectTweenInfo = TweenInfo.new(
    1, --Time
    Enum.EasingStyle.Back, --Easing Style
    Enum.EasingDirection.InOut, --Easing Direction
    0, --Repeat Count
    true, --Will reverse?
    0 --Delay
)

tool.Activated:Connect(function()
    if not onCooldown then
        print(tool.Name, "was activated")
        local clone = part:Clone()
        clone.Parent = workspace
        clone.Position = tool.Handle.Position
        
        local sizingTween = TweenService:Create(clone, sizingTweenInfo, {Size = Vector3.new(100,100,100)})
        local reflectTween = TweenService:Create(clone, reflectTweenInfo, {Transparency = 5})
        sizingTween:Play()
        reflectTween:Play()
#

        reflectTween.Completed:Connect(function(playbackState: Enum.PlaybackState) 
            for _, i in workspace:GetPartsInPart(clone) do
                if i.Anchored == true then
                    print("Ignoring", i.Name)
                elseif i.Anchored == false then
                    print("Anchoring", i.Name)
                    i.Anchored = true
                end
            end
            
            
            local finishedTween = TweenService:Create(clone, sizingTweenInfo, {Size = Vector3.new(0.1,0.1,0.1)})
            task.wait(5) --Length attack will stay out for
            finishedTween:Play()
            finishedTween.Completed:Connect(function(playbackState: Enum.PlaybackState) 
                clone.Parent = nil --Deletes part till next call
            end)
        end)
    end
    
    if onCooldown then
        print("Wait for", cooldownTime.Value, "seconds")

        return
    else
        onCooldown = true
        tool.CooldownTime.Value = maxTime
        
        while onCooldown do --If the cooldown is over then
            if cooldownTime.Value == 0 then
                onCooldown = false
                print("Cooldown finished")
                break
            else --If the cooldown time is not 0
                cooldownTime.Value -= 1                
                task.wait(1)
            end
        end
    end
end)
#

Had to split the code into 2 it was too long for discord, probably could of just trimmed it down to only the parts necessary

lunar sapphire
#

prob bc it says it’s ignoring them

wise rune
#

bro

woeful radish
#

specifically unanchored?

#

@wise rune