Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

GetTouchingParts() is returning parts that aren't near or touching the part?

Asked by 4 years ago
Edited 4 years ago

I was recently working on a placement system and I was working on checking if the part they are placing is colliding with other parts.

For some reason even if the part they are placing is off the ground it still says that it is colliding with the baseplate.

This confuses me beyond belief.

Heres my code.

function CollisionCheck()
    local TempTouchedEvent = CurrentlyPlacingModel.PrimaryPart.Touched:Connect(function()end)

    if #CurrentlyPlacingModel.PrimaryPart:GetTouchingParts() > (#CurrentlyPlacingModel:GetChildren() - 1) then
        for Index, Object in pairs(CurrentlyPlacingModel:GetChildren()) do
            if Object:IsA("BasePart") and Object.Name ~= "Hitbox" then
                TweenService:Create(Object, TweenInfo.new(CollisionDetectedColorChangeTweenTime, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut), {Color = BrickColor.new("Bright red").Color}):Play()

                delay(CollisionDetectedColorChangeTweenTime, function()
                    TweenService:Create(Object, TweenInfo.new(CollisionDetectedColorChangeTweenTime, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut), {Color = BrickColor.new("Bright green").Color}):Play()
                end)
            end
        end

        return true
    end

    TempTouchedEvent:Disconnect()
    TempTouchedEvent = nil

    return false
end

Thank you and if you have any questions or need more code please let me know.

Also heres a gif. https://gyazo.com/6169374cfa019d9e8cb2d9ae7910ad35

Answer this question